diff options
Diffstat (limited to 'eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt')
349 files changed, 14118 insertions, 0 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/build/AaptParserTest.java b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/build/AaptParserTest.java new file mode 100644 index 000000000..af4e2b7c5 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/build/AaptParserTest.java @@ -0,0 +1,200 @@ +/* + * 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.build; + +import com.android.ide.eclipse.adt.AdtConstants; +import com.android.ide.eclipse.adt.AdtPlugin; +import com.android.ide.eclipse.adt.internal.editors.layout.refactoring.AdtProjectTest; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IMarker; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; + +import java.io.File; +import java.util.Collections; +import java.util.List; + +public class AaptParserTest extends AdtProjectTest { + + public void testBasic() throws Exception { + // Test the "at 'property' with value 'value' range matching included with most aapt errors + checkRanges("quickfix1.xml", "res/layout/quickfix1.xml", + "quickfix1.xml:7: error: Error: No resource found that matches the given name (at" + + " 'text' with value '@string/firststring').", + "android:text=\"^@string/firststring\"", + "android:text=\"@string/firststring^\""); + } + + public void testRange1() throws Exception { + // Check that when the actual aapt error occurs on a line later than the original error + // line, the forward search which looks for a value match does not stop on an + // earlier line that happens to have the same value prefix + checkRanges("aapterror1.xml", "res/layout/aapterror1.xml", + "aapterror1.xml:5: error: Error: Integer types not allowed (at " + + "'layout_marginBottom' with value '50').", + "marginBottom=\"^50\"", "marginBottom=\"50^\""); + } + + public void testRange2() throws Exception { + // Check that when we have a duplicate resource error, we highlight both the original + // property and the original definition. + // This tests the second, duplicate declaration ration. + checkRanges("aapterror2.xml", "res/values/aapterror2.xml", + "aapterror2.xml:7: error: Resource entry repeatedStyle1 already has bag item " + + "android:gravity.", + "<item name=\"^android:gravity\">bottom</item>", + "<item name=\"android:gravity^\">bottom</item>"); + } + + public void testRange3() throws Exception { + // Check that when we have a duplicate resource error, we highlight both the original + // property and the original definition. + // This tests the original definition. Note that we don't have enough position info + // so we simply highlight the whitespace portion of the line. + checkRanges("aapterror2.xml", "res/values/aapterror2.xml", + "aapterror2.xml:4: Originally defined here.", + "^<item name=\"android:gravity\">left</item>", + "<item name=\"android:gravity\">left</item>^"); + } + + public void testRange4() throws Exception { + // Check for aapt error which occurs when the attribute name in an item style declaration + // is nonexistent + checkRanges("aapterror3.xml", "res/values/aapterror3.xml", + "aapterror3.xml:4: error: Error: No resource found that matches the given name: " + + "attr 'nonexistent'.", + "<item name=\"^nonexistent\">5</item>", + "<item name=\"nonexistent^\">5</item>"); + } + + public void testRange5() throws Exception { + // Test missing resource name + checkRanges("aapterror4.xml", "res/values/aapterror4.xml", + "aapterror4.xml:3: error: A 'name' attribute is required for <style>", + "<^style>", + "<style^>"); + } + + public void testRange6() throws Exception { + checkRanges("aapterror4.xml", "res/values/aapterror4.xml", + "aapterror4.xml:6: error: A 'type' attribute is required for <item>", + "<^item></item>", + "<item^></item>"); + } + + public void testRange7() throws Exception { + // Test missing resource name + checkRanges("aapterror4.xml", "res/values/aapterror4.xml", + "aapterror4.xml:6: error: A 'name' attribute is required for <item>", + "<^item></item>", + "<item^></item>"); + } + + // This test is disabled because I can't find a useful scenario for handling this error + // message. When this error occurs, we will also get a warning on a missing attribute, and + // that warning already underlines the element name. + //public void testRange8() throws Exception { + // // Test missing resource name + // checkRanges("aapterror4.xml", "res/values/aapterror4.xml", + // "aapterror4.xml:4: error: Error: Resource id cannot be an empty string: attr ''.", + // " ^<item />", + // " <item />^"); + //} + + public void testRange9() throws Exception { + // Test missing resource name + checkRanges("aapterror5.xml", "res/values/aapterror5.xml", + "aapterror5.xml:4: error: Error: String types not allowed (at " + + "'android:layout_width' with value '').", + " <item name=\"^android:layout_width\"></item>", + " <item name=\"android:layout_width^\"></item>"); + } + + public void testRange10() throws Exception { + // Test missing resource name + checkRanges("aapterror6.xml", "res/layout/aapterror6.xml", + "aapterror6.xml:5: error: Error: String types not allowed (at 'layout_marginTop'" + + " with value '').", + "android:layout_marginTop=^\"\"", + "android:layout_marginTop=\"\"^"); + } + + public void testRange11() throws Exception { + // Test missing resource name + checkRanges("aapterror6.xml", "res/layout/aapterror6.xml", + "aapterror1.xml:5: error: Error: String types not allowed (at 'layout_marginLeft'" + + " with value '').", + "android:layout_marginLeft=^''", + "android:layout_marginLeft=''^"); + } + + public void testRange12() throws Exception { + // Test missing resource name + checkRanges("aapterror7.xml", "res/layout/aapterror7.xml", + "aapterror7.xml:5: error: Error: String types not allowed (at 'id'" + + " with value '').", + "android:id=^\"\"", + "android:id=\"\"^"); + } + + private void checkRanges(String name, String destPath, String aaptError, + String expectCaretBegin, String expectCaretEnd) + throws Exception { + IProject project = getProject(); + IFile file = getTestDataFile(project, name, destPath); + + // Make file paths absolute + String osRoot = project.getLocation().toOSString(); + String fileRelativePath = file.getProjectRelativePath().toPortableString(); + String filePath = osRoot + File.separator + fileRelativePath; + String originalError = filePath + aaptError.substring(aaptError.indexOf(':')); + List<String> errors = Collections.singletonList(originalError); + + // Remove anything already placed there by the project create/build automatic + // (this usually only happens while debugging so the background thread has a chance + // to get things going) + IMarker[] markers = file.findMarkers(AdtConstants.MARKER_AAPT_COMPILE, true, + IResource.DEPTH_ZERO); + for (IMarker marker : markers) { + marker.delete(); + } + + AaptParser.parseOutput(errors, project); + markers = file.findMarkers(AdtConstants.MARKER_AAPT_COMPILE, true, + IResource.DEPTH_ZERO); + assertNotNull(markers); + assertEquals(1, markers.length); + + String fileContents = AdtPlugin.readFile(file); + int rangeBegin = getCaretOffset(file, expectCaretBegin); + int rangeEnd = getCaretOffset(file, expectCaretEnd); + + // Check text range + IMarker marker = markers[0]; + String message = marker.getAttribute(IMarker.MESSAGE, ""); //$NON-NLS-1$ + String simplerMessage = aaptError.substring(aaptError.indexOf(' ') + 1); + assertEquals(simplerMessage, message); + int start = marker.getAttribute(IMarker.CHAR_START, 0); + int end = marker.getAttribute(IMarker.CHAR_END, 0); + + assertEquals("Wrong start offset, expected " + expectCaretBegin + " but was " + + getCaretContext(fileContents, start), rangeBegin, start); + assertEquals("Wrong end offset, expected " + expectCaretEnd + " but was " + + getCaretContext(fileContents, end), rangeEnd, end); + } +} diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/build/AaptQuickFixTest.java b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/build/AaptQuickFixTest.java new file mode 100644 index 000000000..cc3504f58 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/build/AaptQuickFixTest.java @@ -0,0 +1,289 @@ +/* + * 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.build; + +import static com.android.SdkConstants.FD_RES; +import static com.android.SdkConstants.FD_RES_COLOR; +import static com.android.SdkConstants.FD_RES_LAYOUT; + +import com.android.ide.eclipse.adt.AdtConstants; +import com.android.ide.eclipse.adt.AdtPlugin; +import com.android.ide.eclipse.adt.AdtUtils; +import com.android.ide.eclipse.adt.internal.editors.AndroidXmlEditor; +import com.android.ide.eclipse.adt.internal.editors.layout.refactoring.AdtProjectTest; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IMarker; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Path; +import org.eclipse.jface.text.Document; +import org.eclipse.jface.text.IDocument; +import org.eclipse.jface.text.contentassist.ICompletionProposal; +import org.eclipse.jface.text.quickassist.IQuickAssistInvocationContext; +import org.eclipse.jface.text.source.ISourceViewer; +import org.eclipse.swt.graphics.Point; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.IMarkerResolution; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.ide.IDE; +import org.eclipse.ui.part.FileEditorInput; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +public class AaptQuickFixTest extends AdtProjectTest { + @Override + protected boolean testCaseNeedsUniqueProject() { + // Make a separate test project for this test such that we don't pollute code assist + // tests with our new resources + return true; + } + + public void testQuickFix1() throws Exception { + // Test adding a value into an existing file (res/values/strings.xml) + checkResourceFix("quickfix1.xml", "android:text=\"@string/firs^tstring\"", + "res/values/strings.xml"); + } + + public void testQuickFix2() throws Exception { + // Test adding a value into a new file (res/values/dimens.xml, will be created) + checkResourceFix("quickfix1.xml", "android:layout_width=\"@dimen/^testdimen\"", + "res/values/dimens.xml"); + } + + public void testQuickFix3() throws Exception { + // Test adding a file based resource (uses new file wizard machinery) + checkResourceFix("quickfix1.xml", "layout=\"@layout/^testlayout\"", + "res/layout/testlayout.xml"); + } + + public void testQuickFix4() throws Exception { + // Test adding a value into a new file (res/values/dimens.xml, will be created) + checkNamespaceFix("quickfix2.xml", "<c^olor"); + } + + private void checkResourceFix(String name, String caretLocation, String expectedNewPath) + throws Exception { + IProject project = getProject(); + IFile file = getTestDataFile(project, name, FD_RES + "/" + FD_RES_LAYOUT + "/" + name); + + // Determine the offset + final int offset = getCaretOffset(file, caretLocation); + + + String osRoot = project.getLocation().toOSString(); + List<String> errors = new ArrayList<String>(); + String fileRelativePath = file.getProjectRelativePath().toPortableString(); + String filePath = osRoot + File.separator + fileRelativePath; + // Run AaptParser such that markers are added... + // When debugging these tests, the project gets a chance to build itself so + // the real aapt errors are there. But when the test is run directly, aapt has + // not yet run. I tried waiting for the build (using the code in SampleProjectTest) + // but this had various adverse effects (exception popups from the Eclipse debugger + // etc) so instead this test just hardcodes the aapt errors that should be + // observed on quickfix1.xml. + assertEquals("Unit test is hardcoded to errors for quickfix1.xml", "quickfix1.xml", name); + errors.add(filePath + ":7: error: Error: No resource found that matches the given name" + + " (at 'text' with value '@string/firststring')."); + errors.add(filePath + ":7: error: Error: No resource found that matches the given name" + + " (at 'layout_width' with value '@dimen/testdimen')."); + errors.add(filePath + ":13: error: Error: No resource found that matches the given name" + + " (at 'layout' with value '@layout/testlayout')."); + AaptParser.parseOutput(errors, project); + + AaptQuickFix aaptQuickFix = new AaptQuickFix(); + + // Open file + IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); + assertNotNull(page); + IEditorPart editor = IDE.openEditor(page, file); + assertTrue(editor instanceof AndroidXmlEditor); + AndroidXmlEditor layoutEditor = (AndroidXmlEditor) editor; + final ISourceViewer viewer = layoutEditor.getStructuredSourceViewer(); + + // Test marker resolution. + IMarker[] markers = file.findMarkers(AdtConstants.MARKER_AAPT_COMPILE, true, + IResource.DEPTH_ZERO); + for (IMarker marker : markers) { + int start = marker.getAttribute(IMarker.CHAR_START, 0); + int end = marker.getAttribute(IMarker.CHAR_END, 0); + if (offset >= start && offset <= end) { + // Found the target marker. Now check the marker resolution of it. + assertTrue(aaptQuickFix.hasResolutions(marker)); + IMarkerResolution[] resolutions = aaptQuickFix.getResolutions(marker); + assertNotNull(resolutions); + assertEquals(1, resolutions.length); + IMarkerResolution resolution = resolutions[0]; + assertNotNull(resolution); + assertTrue(resolution.getLabel().contains("Create resource")); + + // Not running marker yet -- if we create the files here they already + // exist when the quick assist code runs. (The quick fix and the quick assist + // mostly share code for the implementation anyway.) + //resolution.run(marker); + break; + } + } + + // Next test quick assist. + + IQuickAssistInvocationContext invocationContext = new IQuickAssistInvocationContext() { + @Override + public int getLength() { + return 0; + } + + @Override + public int getOffset() { + return offset; + } + + @Override + public ISourceViewer getSourceViewer() { + return viewer; + } + }; + ICompletionProposal[] proposals = aaptQuickFix + .computeQuickAssistProposals(invocationContext); + assertNotNull(proposals); + assertTrue(proposals.length == 1); + ICompletionProposal proposal = proposals[0]; + + assertNotNull(proposal.getAdditionalProposalInfo()); + assertNotNull(proposal.getImage()); + assertTrue(proposal.getDisplayString().contains("Create resource")); + + IDocument document = new Document(); + String fileContent = AdtPlugin.readFile(file); + document.set(fileContent); + + // Apply quick fix + proposal.apply(document); + + IPath path = new Path(expectedNewPath); + IFile newFile = project.getFile(path); + assertNotNull(path.toPortableString(), newFile); + + // Ensure that the newly created file was opened + IEditorPart currentFile = AdtUtils.getActiveEditor(); + assertEquals(newFile.getProjectRelativePath(), + ((FileEditorInput) currentFile.getEditorInput()).getFile().getProjectRelativePath()); + + // Look up caret offset + assertTrue(currentFile != null ? currentFile.getClass().getName() : "null", + currentFile instanceof AndroidXmlEditor); + AndroidXmlEditor newEditor = (AndroidXmlEditor) currentFile; + ISourceViewer newViewer = newEditor.getStructuredSourceViewer(); + Point selectedRange = newViewer.getSelectedRange(); + + String newFileContents = AdtPlugin.readFile(newFile); + + // Insert selection markers -- [ ] for the selection range, ^ for the caret + String newFileWithCaret = addSelection(newFileContents, selectedRange); + newFileWithCaret = removeSessionData(newFileWithCaret); + + assertEqualsGolden(name, newFileWithCaret); + } + + private void checkNamespaceFix(String name, String caretLocation) + throws Exception { + IProject project = getProject(); + IFile file = getTestDataFile(project, name, FD_RES + "/" + FD_RES_COLOR + "/" + name); + + // Determine the offset + final int offset = getCaretOffset(file, caretLocation); + + String osRoot = project.getLocation().toOSString(); + List<String> errors = new ArrayList<String>(); + String fileRelativePath = file.getProjectRelativePath().toPortableString(); + String filePath = osRoot + File.separator + fileRelativePath; + assertEquals("Unit test is hardcoded to errors for quickfix2.xml", "quickfix2.xml", name); + errors.add(filePath + ":5: error: Error parsing XML: unbound prefix"); + AaptParser.parseOutput(errors, project); + + AaptQuickFix aaptQuickFix = new AaptQuickFix(); + + // Open file + IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); + assertNotNull(page); + IEditorPart editor = IDE.openEditor(page, file); + assertTrue(editor instanceof AndroidXmlEditor); + AndroidXmlEditor layoutEditor = (AndroidXmlEditor) editor; + final ISourceViewer viewer = layoutEditor.getStructuredSourceViewer(); + + // Test marker resolution. + IMarker[] markers = file.findMarkers(AdtConstants.MARKER_AAPT_COMPILE, true, + IResource.DEPTH_ZERO); + assertEquals(1, markers.length); + IMarker marker = markers[0]; + // Found the target marker. Now check the marker resolution of it. + assertTrue(aaptQuickFix.hasResolutions(marker)); + IMarkerResolution[] resolutions = aaptQuickFix.getResolutions(marker); + assertNotNull(resolutions); + assertEquals(1, resolutions.length); + IMarkerResolution resolution = resolutions[0]; + assertNotNull(resolution); + assertTrue(resolution.getLabel().contains("Insert namespace")); + + // Next test quick assist. + + IQuickAssistInvocationContext invocationContext = new IQuickAssistInvocationContext() { + @Override + public int getLength() { + return 0; + } + + @Override + public int getOffset() { + return offset; + } + + @Override + public ISourceViewer getSourceViewer() { + return viewer; + } + }; + ICompletionProposal[] proposals = aaptQuickFix + .computeQuickAssistProposals(invocationContext); + assertNotNull(proposals); + assertTrue(proposals.length == 1); + ICompletionProposal proposal = proposals[0]; + + assertNotNull(proposal.getAdditionalProposalInfo()); + assertNotNull(proposal.getImage()); + assertTrue(proposal.getDisplayString().contains("Insert namespace")); + + // Open the file to ensure we can get an XML model with getExistingModelForEdit: + AdtPlugin.openFile(file, null); + IEditorPart newEditor = AdtUtils.getActiveEditor(); + assertTrue(newEditor instanceof AndroidXmlEditor); + + AndroidXmlEditor xmlEditor = (AndroidXmlEditor) newEditor; + IDocument document = xmlEditor.getStructuredSourceViewer().getDocument(); + + // Apply quick fix + String before = document.get(); + proposal.apply(document); + String after = document.get(); + String diff = getDiff(before, after); + assertEqualsGolden(name, diff); + } +} diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/AndroidContentAssistTest.java b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/AndroidContentAssistTest.java new file mode 100644 index 000000000..700e68bad --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/AndroidContentAssistTest.java @@ -0,0 +1,990 @@ +/* + + * 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; + +import static com.android.SdkConstants.FD_RES; +import static com.android.SdkConstants.FD_RES_ANIM; +import static com.android.SdkConstants.FD_RES_ANIMATOR; +import static com.android.SdkConstants.FD_RES_COLOR; +import static com.android.SdkConstants.FD_RES_DRAWABLE; + +import com.android.ide.eclipse.adt.AdtPlugin; +import com.android.ide.eclipse.adt.internal.editors.animator.AnimationContentAssist; +import com.android.ide.eclipse.adt.internal.editors.color.ColorContentAssist; +import com.android.ide.eclipse.adt.internal.editors.common.CommonXmlEditor; +import com.android.ide.eclipse.adt.internal.editors.descriptors.AttributeDescriptor; +import com.android.ide.eclipse.adt.internal.editors.descriptors.ElementDescriptor; +import com.android.ide.eclipse.adt.internal.editors.drawable.DrawableContentAssist; +import com.android.ide.eclipse.adt.internal.editors.layout.LayoutContentAssist; +import com.android.ide.eclipse.adt.internal.editors.layout.descriptors.ViewElementDescriptor; +import com.android.ide.eclipse.adt.internal.editors.layout.refactoring.AdtProjectTest; +import com.android.ide.eclipse.adt.internal.editors.manifest.ManifestContentAssist; +import com.android.ide.eclipse.adt.internal.editors.manifest.ManifestEditor; +import com.android.ide.eclipse.adt.internal.editors.uimodel.UiElementNode; +import com.android.ide.eclipse.adt.internal.editors.values.ValuesContentAssist; + +import org.eclipse.core.resources.IFile; +import org.eclipse.jface.text.Document; +import org.eclipse.jface.text.IDocument; +import org.eclipse.jface.text.contentassist.ICompletionProposal; +import org.eclipse.jface.text.source.ISourceViewer; +import org.eclipse.swt.graphics.Point; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.ide.IDE; + +@SuppressWarnings("javadoc") +public class AndroidContentAssistTest extends AdtProjectTest { + private static final String CARET = "^"; //$NON-NLS-1$ + + @Override + protected boolean testCaseNeedsUniqueProject() { + return true; + } + + public void testStartsWith() { + assertTrue(AndroidContentAssist.startsWith("", "")); + assertTrue(AndroidContentAssist.startsWith("a", "")); + assertTrue(AndroidContentAssist.startsWith("A", "")); + assertTrue(AndroidContentAssist.startsWith("A", "a")); + assertTrue(AndroidContentAssist.startsWith("A", "A")); + assertTrue(AndroidContentAssist.startsWith("Ab", "a")); + assertTrue(AndroidContentAssist.startsWith("ab", "A")); + assertTrue(AndroidContentAssist.startsWith("ab", "AB")); + assertFalse(AndroidContentAssist.startsWith("ab", "ABc")); + assertFalse(AndroidContentAssist.startsWith("", "ABc")); + } + + public void testNameStartsWith() { + String fullWord = "android:marginTop"; + for (int i = 0; i < fullWord.length(); i++) { + assertTrue(i + ":" + fullWord.substring(0, i), + AndroidContentAssist.nameStartsWith( + "android:layout_marginTop", fullWord.substring(0, i), "android:")); + } + + fullWord = "android:layout_marginTop"; + for (int i = 0; i < fullWord.length(); i++) { + assertTrue(i + ":" + fullWord.substring(0, i), + AndroidContentAssist.nameStartsWith("android:layout_marginTop", fullWord + .substring(0, i), "android:")); + } + + fullWord = "layout_marginTop"; + for (int i = 0; i < fullWord.length(); i++) { + assertTrue(i + ":" + fullWord.substring(0, i), + AndroidContentAssist.nameStartsWith("android:layout_marginTop", fullWord + .substring(0, i), "android:")); + } + + fullWord = "marginTop"; + for (int i = 0; i < fullWord.length(); i++) { + assertTrue(i + ":" + fullWord.substring(0, i), + AndroidContentAssist.nameStartsWith("android:layout_marginTop", fullWord + .substring(0, i), "android:")); + } + + assertFalse(AndroidContentAssist.nameStartsWith("ab", "ABc", null)); + assertFalse(AndroidContentAssist.nameStartsWith("", "ABc", null)); + } + + public void testCompletion1() throws Exception { + // Change attribute name completion + checkLayoutCompletion("completion1.xml", "layout_w^idth=\"fill_parent\""); + } + + public void testCompletion2() throws Exception { + // Check attribute value completion for enum + checkLayoutCompletion("completion1.xml", "layout_width=\"^fill_parent\""); + } + + public void testCompletion3() throws Exception { + // Check attribute value completion for enum with a prefix + checkLayoutCompletion("completion1.xml", "layout_width=\"fi^ll_parent\""); + } + + public void testCompletion4() throws Exception { + // Check attribute value completion on units + checkLayoutCompletion("completion1.xml", "marginBottom=\"50^\""); + } + + public void testCompletion5() throws Exception { + // Check attribute value completion on units with prefix + checkLayoutCompletion("completion1.xml", "layout_marginLeft=\"50d^p\""); + } + + public void testCompletion6() throws Exception { + // Check resource sorting - "style" should bubble to the top for a style attribute + checkLayoutCompletion("completion1.xml", "style=\"@android:^style/Widget.Button\""); + } + + public void testCompletion7a() throws Exception { + // Check flags (multiple values inside a single XML value, separated by | - where + // the prefix is reset as soon as you pass each | ) + checkLayoutCompletion("completion1.xml", "android:gravity=\"l^eft|bottom\""); + } + + public void testCompletion7b() throws Exception { + checkLayoutCompletion("completion1.xml", "android:gravity=\"left|b^ottom\""); + } + + public void testCompletion8() throws Exception { + // Test completion right at the "=" sign; this will be taken to be the last + // character of the attribute name (the caret is between the last char and before + // the = characters), so it should match a single attribute + checkLayoutCompletion("completion1.xml", "layout_width^=\"fill_parent\""); + } + + public void testCompletion9() throws Exception { + // Test completion right after the "=" sign; this will be taken to be the beginning + // of the attribute value, but all values will also include a leading quote + checkLayoutCompletion("completion1.xml", "layout_width=^\"fill_parent\""); + } + + public void testCompletion10() throws Exception { + // Test completion of element names + checkLayoutCompletion("completion1.xml", "<T^extView"); + } + + public void testCompletion11() throws Exception { + // Test completion of element names at the outside of the <. This should include + // all the elements too (along with the leading <). + checkLayoutCompletion("completion1.xml", "^<TextView"); + } + + public void testCompletion12() throws Exception { + // Test completion of element names inside a nested XML; ensure that this will + // correctly compute element names, not previous attribute + checkLayoutCompletion("completion1.xml", "btn_default\">^</FrameLayout>"); + } + + public void testCompletion13a() throws Exception { + checkLayoutCompletion("completion2.xml", "gravity=\"left|bottom|^cen"); + } + + public void testCompletion13b() throws Exception { + checkLayoutCompletion("completion2.xml", "gravity=\"left|bottom|cen^"); + } + + public void testCompletion13c() throws Exception { + checkLayoutCompletion("completion2.xml", "gravity=\"left|bottom^|cen"); + } + + public void testCompletion14() throws Exception { + // Test completion of permissions + checkManifestCompletion("manifest.xml", "android.permission.ACC^ESS_NETWORK_STATE"); + } + + public void testCompletion15() throws Exception { + // Test completion of intents + checkManifestCompletion("manifest.xml", "android.intent.category.L^AUNCHER"); + } + + public void testCompletion16() throws Exception { + // Test completion of top level elements + checkManifestCompletion("manifest.xml", "<^application android:i"); + } + + public void testCompletion17() throws Exception { + // Test completion of attributes on the manifest element + checkManifestCompletion("manifest.xml", "^android:versionCode=\"1\""); + } + + public void testCompletion18() throws Exception { + // Test completion of attributes on the manifest element + checkManifestCompletion("manifest.xml", + "<activity android:^name=\".TestActivity\""); + } + + public void testCompletion19() throws Exception { + // Test special case where completing on a new element in an otherwise blank line + // does not add in full completion (with closing tags) + checkLayoutCompletion("broken3.xml", "<EditT^"); + } + + public void testCompletion20() throws Exception { + checkLayoutCompletion("broken1.xml", "android:textColorHigh^"); + } + + public void testCompletion21() throws Exception { + checkLayoutCompletion("broken2.xml", "style=^"); + } + + public void testCompletion22() throws Exception { + // Test completion where the cursor is inside an element (e.g. the next + // char is NOT a <) - should not complete with end tags + checkLayoutCompletion("completion4.xml", "<Button^"); + } + + // Test completion in style files + + public void testCompletion23() throws Exception { + checkResourceCompletion("completionvalues1.xml", "android:textS^ize"); + } + + public void testCompletion24() throws Exception { + checkResourceCompletion("completionvalues1.xml", "17^sp"); + } + + public void testCompletion25() throws Exception { + checkResourceCompletion("completionvalues1.xml", "textColor\">^@color/title_color</item>"); + } + + public void testCompletion26() throws Exception { + checkResourceCompletion("completionvalues1.xml", + "<item name=\"android:shadowColor\">@an^</item>"); + } + + public void testCompletion27() throws Exception { + checkResourceCompletion("completionvalues1.xml", + "<item name=\"android:gravity\">^ </item>"); + } + + public void testCompletion28() throws Exception { + checkResourceCompletion("completionvalues1.xml", + "<item name=\"android:gravity\"> ^</item>"); + } + + public void testCompletion29() throws Exception { + checkResourceCompletion("completionvalues1.xml", "<item name=\"gr^\">"); + } + + public void testCompletion30() throws Exception { + checkResourceCompletion("completionvalues1.xml", "<item name=\"an^\">"); + } + + public void testCompletion31() throws Exception { + checkResourceCompletion("completionvalues1.xml", "<item ^></item>"); + } + + public void testCompletion32() throws Exception { + checkResourceCompletion("completionvalues1.xml", "<item name=\"^\"></item>"); + } + + public void testCompletion33() throws Exception { + checkResourceCompletion("completionvalues1.xml", + "<item name=\"android:allowSingleTap\">^</item>"); + } + + public void testCompletion34() throws Exception { + checkResourceCompletion("completionvalues1.xml", + "<item name=\"android:alwaysDrawnWithCache\">^ false </item>"); + } + + public void testCompletion35() throws Exception { + checkResourceCompletion("completionvalues1.xml", + "<item name=\"android:alwaysDrawnWithCache\"> ^false </item>"); + } + + public void testCompletion36() throws Exception { + checkResourceCompletion("completionvalues1.xml", + "<item name=\"android:alwaysDrawnWithCache\"> f^alse </item>"); + } + + public void testCompletion37() throws Exception { + checkResourceCompletion("completionvalues1.xml", + "<item name=\"android:orientation\">h^</item>"); + } + + public void testCompletion38() throws Exception { + checkResourceCompletion("completionvalues1.xml", + " c^"); + } + + public void testCompletion39() throws Exception { + // If you are at the end of a closing quote (but with no space), completion should + // include a separating space. + checkLayoutCompletion("completion1.xml", "marginBottom=\"50\"^"); + } + + public void testCompletion40() throws Exception { + // Same as test 39 but with single quote + checkLayoutCompletion("completion5.xml", "android:id='@+id/button2'^"); + } + + public void testCompletion41() throws Exception { + // Test prefix matching on layout_ with namespace prefix + checkLayoutCompletion("completion8.xml", "android:mar^=\"50dp\""); + } + + public void testCompletion42() throws Exception { + // Test prefix matching on layout_ with namespace prefix + checkLayoutCompletion("completion8.xml", "android:w^i=\"100\""); + } + + public void testCompletion43() throws Exception { + // Test prefix matching on layout_ without namespace prefix + checkLayoutCompletion("completion8.xml", "mar^=\"60dp\""); + } + + public void testCompletion44() throws Exception { + // Test prefix matching on layout_ without namespace prefix + checkLayoutCompletion("completion8.xml", "android:layo^ut_width=\"fill_parent\""); + } + + public void testCompletion45() throws Exception { + // Test top level elements in colors + checkColorCompletion("color1.xml", "^<selector"); + } + + public void testCompletion46a() throws Exception { + // Test children of selector: should offer item + checkColorCompletion("color1.xml", "^<item android"); + } + + public void testCompletion46b() throws Exception { + // Test attribute matching in color files + checkColorCompletion("color1.xml", "<item ^android:state_focused=\"true\"/>"); + } + + public void testCompletion47() throws Exception { + // Check root completion in drawables: should list all drawable root elements + checkDrawableCompletion("drawable1.xml", "^<layer-list"); + } + + public void testCompletion48() throws Exception { + // Check attributes of the layer list + checkDrawableCompletion("drawable1.xml", "^xmlns:android"); + } + + public void testCompletion49() throws Exception { + // Check attributes of the <item> element inside a <layer-list> + checkDrawableCompletion("drawable1.xml", "<item ^></item>"); + } + + public void testCompletion50() throws Exception { + // Check elements nested inside the <item> in a layer list: can use any drawable again + checkDrawableCompletion("drawable1.xml", "<item >^</item>"); + } + + public void testCompletion51() throws Exception { + // Check attributes of <shape> element + checkDrawableCompletion("drawable2.xml", "^android:innerRadiusRatio=\"2\""); + } + + public void testCompletion52() throws Exception { + // Check list of available elements inside a shape + checkDrawableCompletion("drawable2.xml", "^<gradient"); + } + + public void testCompletion53() throws Exception { + // Check list of root anim elements + checkAnimCompletion("anim1.xml", "^<set xmlns"); + } + + public void testCompletion54() throws Exception { + // Check that we can nest inside <set>'s + checkAnimCompletion("anim1.xml", "^<translate android:id="); + } + + public void testCompletion55() throws Exception { + // translate properties + checkAnimCompletion("anim1.xml", "android:^fromXDelta="); + } + + public void testCompletion56() throws Exception { + // alpha properties + checkAnimCompletion("anim1.xml", "android:^fromAlpha="); + } + + public void testCompletion57() throws Exception { + // Fractional properties + checkAnimCompletion("anim1.xml", "android:fromXDelta=\"100^%p\""); + } + + public void testCompletion58() throws Exception { + // Top level animator elements + checkAnimatorCompletion("animator1.xml", "^<set xmlns"); + } + + public void testCompletion59() throws Exception { + // objectAnimator properties + checkAnimatorCompletion("animator1.xml", "android:^duration=\"2000\""); + } + + public void testCompletion60() throws Exception { + // propertyName completion + checkAnimatorCompletion("animator1.xml", "android:propertyName=\"scal^eX\"/>"); + } + + public void testCompletion61() throws Exception { + // Interpolator completion + checkAnimatorCompletion("animator1.xml", + "android:interpolator=\"^@android:anim/bounce_interpolator\""); + } + + public void testCompletion62() throws Exception { + // Test completing inside an element that contains .'s, such as a custom view tag + checkLayoutCompletion("completion9.xml", "android:layout_wi^dth="); + } + + public void testCompletion63() throws Exception { + // Test attribute completion inside a custom view tag + // TODO: This works in a running IDE but not in a test context; figure out why. + //checkLayoutCompletion("completion9.xml", "android:drawable^Top"); + } + + public void testCompletion64() throws Exception { + // Test element completion inside a custom view tag + checkLayoutCompletion("completion9.xml", "^<Button"); + } + + public void testCompletion65() throws Exception { + // Test completion replacement when there is a selection + // (see issue http://code.google.com/p/android/issues/detail?id=18607 ) + checkLayoutCompletion("completion10.xml", "\"[^wrap_content]\""); + } + + public void testCompletion66() throws Exception { + checkResourceCompletion("completionvalues1.xml", "17[^sp]"); + } + + public void testCompletion67() throws Exception { + checkResourceCompletion("completionvalues1.xml", "17[^sp]"); + } + + public void testCompletion68() throws Exception { + checkResourceCompletion("completionvalues1.xml", "[^false]"); + } + + public void testCompletion69() throws Exception { + // Test minimum SDK completion + checkManifestCompletion("manifest.xml", "<uses-sdk android:minSdkVersion=\"^11\" />"); + } + + public void testCompletion70() throws Exception { + checkResourceCompletion("completionvalues2.xml", + "<item name=\"main_layout4\" type=\"layout\">^</item>"); + } + + public void testCompletion71() throws Exception { + checkResourceCompletion("completionvalues2.xml", + "<item name=\"main_layout5\" type=\"string\">@string/^app_name</item>"); + } + + public void testCompletion72() throws Exception { + // Test completion of theme attributes + checkLayoutCompletion("completion11.xml", "?^android:attr/Textapp"); + } + + public void testCompletion73() throws Exception { + checkLayoutCompletion("completion11.xml", "?android:attr/Textapp^"); + } + + public void testCompletion74() throws Exception { + checkLayoutCompletion("completion11.xml", "?and^roid:attr/Textapp"); + } + + public void testCompletion75() throws Exception { + // Test <include> attributes + checkLayoutCompletion("completion12.xml", "<include ^/>"); + } + + public void testComplation76() throws Exception { + // Test theme completion with implicit attr + checkLayoutCompletion("navigation1.xml", "?android:a^ttr/alertDialogStyle"); + } + + public void testComplation77() throws Exception { + // Test <fragment class="^" completion + checkLayoutCompletion("fragmentlayout.xml", "android:name=\"^com"); + } + + public void testComplation78() throws Exception { + // Test <fragment android:name="^" completion + checkLayoutCompletion("fragmentlayout.xml", "class=\"^com"); + } + + public void testComplation79() throws Exception { + // Test tools context completion + checkLayoutCompletion("completion11.xml", "tools:context=\"^.MainActivity\""); + } + + public void testComplation80() throws Exception { + // Test manifest class completion + checkManifestCompletion("manifest.xml", "<activity android:name=\"^."); + } + + // TODO: Test <view completion! + + // ---- Test *applying* code completion ---- + + // The following tests check -applying- a specific code completion + // match - this verifies that the document is updated correctly, the + // caret is moved appropriately, etc. + + public void testApplyCompletion1() throws Exception { + // Change attribute name completion + checkApplyLayoutCompletion("completion1.xml", "layout_w^idth=\"fill_parent\"", + "android:layout_weight"); + } + + public void testApplyCompletion2() throws Exception { + // Check attribute value completion for enum + checkApplyLayoutCompletion("completion1.xml", "layout_width=\"^fill_parent\"", + "match_parent"); + } + + public void testApplyCompletion3() throws Exception { + // Check attribute value completion for enum with a prefix + checkApplyLayoutCompletion("completion1.xml", "layout_width=\"fi^ll_parent\"", + "fill_parent"); + } + + public void testApplyCompletion4() throws Exception { + // Check attribute value completion on units + checkApplyLayoutCompletion("completion1.xml", "marginBottom=\"50^\"", "50mm"); + } + + public void testApplyCompletion5() throws Exception { + // Check attribute value completion on units with prefix + checkApplyLayoutCompletion("completion1.xml", "layout_marginLeft=\"50d^p\"", "50dp"); + } + + public void testApplyCompletion6() throws Exception { + // Check resource sorting - "style" should bubble to the top for a style attribute + checkApplyLayoutCompletion("completion1.xml", "style=\"@android:^style/Widget.Button\"", + "@android:drawable/"); + } + + public void testApplyCompletion7a() throws Exception { + // Check flags (multiple values inside a single XML value, separated by | - where + // the prefix is reset as soon as you pass each | ) + checkApplyLayoutCompletion("completion1.xml", "android:gravity=\"l^eft|bottom\"", + "left"); + // NOTE - this will replace all flag values with the newly selected value. + // That may not be the best behavior - perhaps we should only replace one portion + // of the value. + } + + public void testApplyCompletion7b() throws Exception { + checkApplyLayoutCompletion("completion1.xml", "android:gravity=\"left|b^ottom\"", + "bottom"); + // NOTE - this will replace all flag values with the newly selected value. + // That may not be the best behavior - perhaps we should only replace one portion + // of the value. + } + + public void testApplyCompletion8() throws Exception { + // Test completion right at the "=" sign; this will be taken to be the last + // character of the attribute name (the caret is between the last char and before + // the = characters), so it should match a single attribute + checkApplyLayoutCompletion("completion1.xml", "layout_width^=\"fill_parent\"", + "android:layout_width"); + } + + public void testApplyCompletion9() throws Exception { + // Test completion right after the "=" sign; this will be taken to be the beginning + // of the attribute value, but all values will also include a leading quote + checkApplyLayoutCompletion("completion1.xml", "layout_width=^\"fill_parent\"", + "\"wrap_content\""); + } + + public void testApplyCompletion10() throws Exception { + // Test completion of element names + checkApplyLayoutCompletion("completion1.xml", "<T^extView", "TableLayout"); + } + + public void testApplyCompletion11a() throws Exception { + // Test completion of element names at the outside of the <. This should include + // all the elements too (along with the leading <). + checkApplyLayoutCompletion("completion1.xml", "^<TextView", "<RadioGroup ></RadioGroup>"); + } + + public void testApplyCompletion11b() throws Exception { + // Similar to testApplyCompletion11a, but replacing with an element that does not + // have children (to test the closing tag insertion code) + checkApplyLayoutCompletion("completion1.xml", "^<TextView", "<CheckBox />"); + } + + public void testApplyCompletion12() throws Exception { + // Test completion of element names inside a nested XML; ensure that this will + // correctly compute element names, not previous attribute + checkApplyLayoutCompletion("completion1.xml", "btn_default\">^</FrameLayout>", + "<FrameLayout ></FrameLayout>"); + } + + public void testApplyCompletion13a() throws Exception { + checkApplyLayoutCompletion("completion2.xml", "gravity=\"left|bottom|^cen", + "fill_vertical"); + } + + public void testApplyCompletion13b() throws Exception { + checkApplyLayoutCompletion("completion2.xml", "gravity=\"left|bottom|cen^", + "center_horizontal"); + } + + public void testApplyCompletion13c() throws Exception { + checkApplyLayoutCompletion("completion2.xml", "gravity=\"left|bottom^|cen", + "bottom|fill_horizontal"); + } + + public void testApplyCompletion14() throws Exception { + // Test special case where completing on a new element in an otherwise blank line + // does not add in full completion (with closing tags) + checkApplyLayoutCompletion("broken3.xml", "<EditT^", "EditText />"); + } + + public void testApplyCompletion15() throws Exception { + checkApplyLayoutCompletion("broken1.xml", "android:textColorHigh^", + "android:textColorHighlight"); + } + + public void testApplyCompletion16() throws Exception { + checkApplyLayoutCompletion("broken2.xml", "style=^", + "\"@android:\""); + } + + public void testApplyCompletion17() throws Exception { + // Make sure that completion right before a / inside an element still + // inserts the ="" part (e.g. handles it as "insertNew) + checkApplyLayoutCompletion("completion3.xml", "<EditText ^/>", + "android:textColorHighlight"); + } + + public void testApplyCompletion18() throws Exception { + // Make sure that completion right before a > inside an element still + // inserts the ="" part (e.g. handles it as "insertNew) + checkApplyLayoutCompletion("completion3.xml", "<Button ^></Button>", + "android:paddingRight"); + } + + public void testApplyCompletion19() throws Exception { + // Test completion with single quotes (apostrophe) + checkApplyLayoutCompletion("completion5.xml", "android:orientation='^'", "horizontal"); + } + + public void testApplyCompletion20() throws Exception { + // Test completion with single quotes (apostrophe) + checkApplyLayoutCompletion("completion5.xml", "android:layout_marginTop='50^dp'", "50pt"); + } + + public void testApplyCompletion21() throws Exception { + // Test completion with single quotes (apostrophe) + checkApplyLayoutCompletion("completion5.xml", "android:layout_width='^wrap_content'", + "match_parent"); + // Still broken - but not a common case + //checkApplyLayoutCompletion("completion5.xml", "android:layout_width=^'wrap_content'", + // "\"match_parent\""); + } + + public void testApplyCompletion22() throws Exception { + // Test completion in an empty string + checkApplyLayoutCompletion("completion6.xml", "android:orientation=\"^\"", "horizontal"); + } + + public void testApplyCompletion23() throws Exception { + // Test completion in an empty string + checkApplyLayoutCompletion("completion7.xml", "android:orientation=\"^", "horizontal"); + } + + // Test completion in style files + + public void testApplyCompletion24a() throws Exception { + checkApplyResourceCompletion("completionvalues1.xml", "android:textS^ize", + "android:textSelectHandleLeft"); + } + + public void testApplyCompletion24b() throws Exception { + checkApplyResourceCompletion("completionvalues1.xml", "17^sp", "17mm"); + } + + public void testApplyCompletion25() throws Exception { + checkApplyResourceCompletion("completionvalues1.xml", + "textColor\">^@color/title_color</item>", "@android:"); + } + + public void testApplyCompletion26() throws Exception { + checkApplyResourceCompletion("completionvalues1.xml", + "<item name=\"android:shadowColor\">@an^</item>", "@android:"); + } + + public void testApplyCompletion27() throws Exception { + checkApplyResourceCompletion("completionvalues1.xml", + "<item name=\"android:gravity\">^ </item>", "center_vertical"); + } + + public void testApplyCompletion28() throws Exception { + checkApplyResourceCompletion("completionvalues1.xml", + "<item name=\"android:gravity\"> ^</item>", "left"); + } + + public void testApplyCompletion29() throws Exception { + checkApplyResourceCompletion("completionvalues1.xml", "<item name=\"gr^\">", + "android:gravity"); + } + + public void testApplyCompletion30() throws Exception { + checkApplyResourceCompletion("completionvalues1.xml", "<item name=\"an^\">", + "android:animateOnClick"); + } + + public void testApplyCompletion31() throws Exception { + checkApplyResourceCompletion("completionvalues1.xml", "<item ^></item>", "name"); + } + + public void testApplyCompletion32() throws Exception { + checkApplyResourceCompletion("completionvalues1.xml", "<item name=\"^\"></item>", + "android:background"); + } + + public void testApplyCompletion33() throws Exception { + checkApplyResourceCompletion("completionvalues1.xml", + "<item name=\"android:allowSingleTap\">^</item>", "true"); + } + + public void testApplyCompletion34() throws Exception { + checkApplyResourceCompletion("completionvalues1.xml", + "<item name=\"android:alwaysDrawnWithCache\">^ false </item>", "true"); + } + + public void testApplyCompletion35() throws Exception { + checkApplyResourceCompletion("completionvalues1.xml", + "<item name=\"android:alwaysDrawnWithCache\"> ^false </item>", "true"); + } + + public void testApplyCompletion36() throws Exception { + checkApplyResourceCompletion("completionvalues1.xml", + "<item name=\"android:alwaysDrawnWithCache\"> f^alse </item>", "false"); + } + + public void testApplyCompletion37() throws Exception { + checkApplyResourceCompletion("completionvalues1.xml", + "<item name=\"android:orientation\">h^</item>", "horizontal"); + } + + public void testApplyCompletion38() throws Exception { + checkApplyResourceCompletion("completionvalues1.xml", + " c^", "center"); + } + + public void testApplyCompletion39() throws Exception { + // If you are at the end of a closing quote (but with no space), completion should + // include a separating space. + checkApplyLayoutCompletion("completion1.xml", "marginBottom=\"50\"^", " android:maxEms"); + } + + public void testApplyCompletion40() throws Exception { + // If you are at the end of a closing quote (but with no space), completion should + // include a separating space. + checkApplyLayoutCompletion("completion5.xml", "android:id='@+id/button2'^", + " android:maxWidth"); + } + + public void testApplyCompletion41() throws Exception { + // Test prefix matching on layout_ with namespace prefix + checkApplyLayoutCompletion("completion8.xml", "android:mar^=\"50dp\"", + "android:layout_marginRight"); + } + + public void testApplyCompletion42() throws Exception { + // Test completion replacement when there is a selection + // (see issue http://code.google.com/p/android/issues/detail?id=18607 ) + checkApplyLayoutCompletion("completion10.xml", "\"[^wrap_content]\"", "fill_parent"); + } + + public void testApplyCompletion43() throws Exception { + // Same as testApplyCompletion42 but with a smaller selection range + checkApplyLayoutCompletion("completion10.xml", "\"[^wrap_c]ontent\"", "fill_parent"); + } + + public void testApplyCompletion44() throws Exception { + checkApplyResourceCompletion("completionvalues1.xml", "[^false]", "true"); + } + + public void testApplyCompletion45() throws Exception { + checkApplyResourceCompletion("completionvalues2.xml", + "@string/^app_name", "@string/hello"); + } + + public void testApplyCompletion46() throws Exception { + checkApplyLayoutCompletion("completion11.xml", + "?android:attr/Textapp^", "?android:attr/textAppearanceLargeInverse"); + } + + public void testApplyCompletion47() throws Exception { + // Test applying <fragment android:name="^" completion + checkApplyLayoutCompletion("fragmentlayout.xml", "class=\"^com", + "android.app.ListFragment"); + } + + // --- Code Completion test infrastructure ---- + + private void checkLayoutCompletion(String name, String caretLocation) throws Exception { + IFile file = getLayoutFile(getProject(), name); + IDE.setDefaultEditor(file, CommonXmlEditor.ID); + checkCompletion(name, file, caretLocation, + new LayoutContentAssist()); + } + + private void checkColorCompletion(String name, String caretLocation) throws Exception { + IFile file = getTestDataFile(getProject(), name, FD_RES + "/" + FD_RES_COLOR + "/" + name); + IDE.setDefaultEditor(file, CommonXmlEditor.ID); + checkCompletion(name, file, caretLocation, new ColorContentAssist()); + } + + private void checkAnimCompletion(String name, String caretLocation) throws Exception { + IFile file = getTestDataFile(getProject(), name, FD_RES + "/" + FD_RES_ANIM + "/" + name); + IDE.setDefaultEditor(file, CommonXmlEditor.ID); + checkCompletion(name, file, caretLocation, new AnimationContentAssist()); + } + + private void checkAnimatorCompletion(String name, String caretLocation) throws Exception { + IFile file = getTestDataFile(getProject(), name, FD_RES + "/" + FD_RES_ANIMATOR + "/" + + name); + IDE.setDefaultEditor(file, CommonXmlEditor.ID); + checkCompletion(name, file, caretLocation, new AnimationContentAssist()); + } + + private void checkDrawableCompletion(String name, String caretLocation) throws Exception { + IFile file = getTestDataFile(getProject(), name, FD_RES + "/" + FD_RES_DRAWABLE + "/" + + name); + IDE.setDefaultEditor(file, CommonXmlEditor.ID); + checkCompletion(name, file, caretLocation, new DrawableContentAssist()); + } + + private void checkManifestCompletion(String name, String caretLocation) throws Exception { + // Manifest files must be named AndroidManifest.xml. Must overwrite to replace + // the default manifest created in the test project. + IFile file = getTestDataFile(getProject(), name, "AndroidManifest.xml", true); + IDE.setDefaultEditor(file, ManifestEditor.ID); + + checkCompletion(name, file, caretLocation, + new ManifestContentAssist()); + } + + private void checkApplyLayoutCompletion(String name, String caretLocation, + String match) throws Exception { + checkApplyCompletion(name, getLayoutFile(getProject(), name), caretLocation, + new LayoutContentAssist(), match); + } + + private void checkResourceCompletion(String name, String caretLocation) throws Exception { + checkCompletion(name, getValueFile(getProject(), name), caretLocation, + new ValuesContentAssist()); + } + + private void checkApplyResourceCompletion(String name, String caretLocation, + String match) throws Exception { + checkApplyCompletion(name, getValueFile(getProject(), name), caretLocation, + new ValuesContentAssist(), match); + } + + private ICompletionProposal[] complete(IFile file, String caretLocation, + AndroidContentAssist assist) throws Exception { + + // Open file + IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); + assertNotNull(page); + IEditorPart editor = IDE.openEditor(page, file); + assertTrue(editor instanceof AndroidXmlEditor); + AndroidXmlEditor xmlEditor = (AndroidXmlEditor) editor; + + UiElementNode root = xmlEditor.getUiRootNode(); + ElementDescriptor descriptor = root.getDescriptor(); + if (descriptor instanceof ViewElementDescriptor) { + ViewElementDescriptor vd = (ViewElementDescriptor) descriptor; + AttributeDescriptor[] attributes = vd.getAttributes(); + assertTrue(Integer.toString(attributes.length), attributes.length > 0); + } + + ISourceViewer viewer = xmlEditor.getStructuredSourceViewer(); + + // Determine the offset, and possibly make text range selections as well + int offset = updateCaret(viewer, caretLocation); + + // Run code completion + ICompletionProposal[] proposals = assist.computeCompletionProposals(viewer, offset); + if (proposals == null) { + proposals = new ICompletionProposal[0]; + } + + editor.getEditorSite().getPage().closeAllEditors(false); + + return proposals; + } + + private void checkApplyCompletion(String basename, IFile file, String caretLocation, + AndroidContentAssist assist, String match) throws Exception { + ICompletionProposal[] proposals = complete(file, caretLocation, assist); + ICompletionProposal chosen = null; + for (ICompletionProposal proposal : proposals) { + if (proposal.getDisplayString().equals(match)) { + chosen = proposal; + break; + } + } + assertNotNull(chosen); + assert chosen != null; // Eclipse null pointer analysis doesn't believe the JUnit assertion + + String fileContent = AdtPlugin.readFile(file); + IDocument document = new Document(); + document.set(fileContent); + + // Apply code completion + chosen.apply(document); + + // Insert caret location as well + Point location = chosen.getSelection(document); + document.replace(location.x, 0, CARET); + + String actual = document.get(); + + int offset = getCaretOffset(fileContent, caretLocation); + String beforeWithCaret = fileContent.substring(0, offset) + CARET + + fileContent.substring(offset); + + String diff = getDiff(beforeWithCaret, actual); + assertTrue(diff + " versus " + actual, diff.length() > 0 || beforeWithCaret.equals(actual)); + + StringBuilder summary = new StringBuilder(); + summary.append("Code completion in " + basename + " for " + caretLocation + " selecting " + + match + ":\n"); + if (diff.length() == 0) { + diff = "No changes"; + } + summary.append(diff); + + // assertEqualsGolden(basename, actual); + assertEqualsGolden(basename, summary.toString(), "diff"); + } + + private void checkCompletion(String basename, IFile file, String caretLocation, + AndroidContentAssist assist) throws Exception { + ICompletionProposal[] proposals = complete(file, caretLocation, assist); + StringBuilder sb = new StringBuilder(1000); + sb.append("Code completion in " + basename + " for " + caretLocation + ":\n"); + for (ICompletionProposal proposal : proposals) { + // TODO: assertNotNull(proposal.getImage()); + int length = sb.length(); + sb.append(proposal.getDisplayString().trim()); + String help = proposal.getAdditionalProposalInfo(); + if (help != null && help.trim().length() > 0) { + sb.append(" : "); + sb.append(help.replace('\n', ' ').trim()); + if (sb.length() > length + 300) { + sb.setLength(length + 300 - "...".length()); + sb.append("..."); + } + } + sb.append('\n'); + } + assertEqualsGolden(basename, sb.toString(), "txt"); + } +} diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/AndroidXmlAutoEditStrategyTest.java b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/AndroidXmlAutoEditStrategyTest.java new file mode 100644 index 000000000..27661b3f2 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/AndroidXmlAutoEditStrategyTest.java @@ -0,0 +1,473 @@ +/* + * 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; + +import com.android.ide.eclipse.adt.internal.editors.layout.refactoring.AdtProjectTest; + +import org.eclipse.core.resources.IFile; +import org.eclipse.jface.text.DocumentCommand; +import org.eclipse.jface.text.IDocument; +import org.eclipse.jface.text.source.ISourceViewer; +import org.eclipse.swt.graphics.Point; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.ide.IDE; + +@SuppressWarnings("javadoc") +public class AndroidXmlAutoEditStrategyTest extends AdtProjectTest { + + public void checkInsertNewline(String before, String after) throws Exception { + AndroidXmlAutoEditStrategy s = new AndroidXmlAutoEditStrategy(); + + // All tests just operate on the "edithandling" document; the contents are + // ignored and replaced with the before-document passed in + IFile file = getLayoutFile(getProject(), "edithandling.xml"); + + IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); + assertNotNull(page); + IEditorPart editor = IDE.openEditor(page, file); + assertTrue(editor instanceof AndroidXmlEditor); + AndroidXmlEditor layoutEditor = (AndroidXmlEditor) editor; + ISourceViewer viewer = layoutEditor.getStructuredSourceViewer(); + + String newDocumentContent = stripCaret(before); + IDocument document = viewer.getDocument(); + document.replace(0, document.getLength(), newDocumentContent); + + // Determine the offset, and possibly make text range selections as well + int offset = updateCaret(viewer, before); + + DocumentCommand c = new TestDocumentCommand(); + c.doit = true; + c.offset = offset; + c.caretOffset = -1; + c.length = 0; + c.text = "\n"; + + s.customizeDocumentCommand(document, c); + + if (c.doit) { + if (c.length == 0 && c.text == null) { + return; + } + + document.replace(c.offset, c.length, c.text); + + int caretOffset = c.offset + c.text.length(); + + // The shiftsCaret flag doesn't behave the way it's documented to + //if (c.shiftsCaret && c.caretOffset != -1) { + if (c.caretOffset != -1) { + caretOffset = c.caretOffset; + } + viewer.setSelectedRange(caretOffset, 0); + } + + String text = document.get(); + Point selectedRange = viewer.getSelectedRange(); + assert selectedRange.y == 0; + String textWithCaret = text; + if (selectedRange.x >= 0) { + textWithCaret = text.substring(0, selectedRange.x) + "^" + + text.substring(selectedRange.x); + } + + assertEquals(after, textWithCaret); + } + + private static String stripCaret(String s) { + int index = s.indexOf('^'); + assertTrue(index != -1); + return s.substring(0, index) + s.substring(index + 1); + } + + public void testCornerCase1() throws Exception { + checkInsertNewline("^", "\n^"); + } + + public void testCornerCase2() throws Exception { + checkInsertNewline( + "\n^", + + "\n\n^"); + } + + public void testCornerCase3() throws Exception { + checkInsertNewline( + " ^", + + " \n" + + " ^"); + } + + public void testSimpleIndentation1() throws Exception { + checkInsertNewline( + " ^ ", + + " \n" + + " ^ "); + } + + public void testSimpleIndentation2() throws Exception { + checkInsertNewline( + "\n" + + " foo^\n", + + "\n" + + " foo\n" + + " ^\n"); + } + + public void testSimpleIndentation3() throws Exception { + checkInsertNewline( + "\n" + + " <newtag>^\n", + + "\n" + + " <newtag>\n" + + " ^\n"); + } + + public void testSimpleIndentation4() throws Exception { + checkInsertNewline( + "\n" + + " <newtag/>^\n", + + "\n" + + " <newtag/>\n" + + " ^\n"); + } + + public void testSimpleIndentation5() throws Exception { + checkInsertNewline( + "\n" + + " <newtag^\n", + "\n" + + " <newtag\n" + + " ^\n"); + } + + public void testSplitAttribute() throws Exception { + checkInsertNewline( + "\n" + + " <newtag ^attribute='value'/>\n", + + "\n" + + " <newtag \n" + + " ^attribute='value'/>\n"); + } + + public void testIndentationInComments1() throws Exception { + // Make sure that inside a comment we ignore tags etc + checkInsertNewline( + "<!--\n foo^\n--->\n", + + "<!--\n foo\n ^\n--->\n"); + } + + public void testIndentationInComments2() throws Exception { + // Make sure that inside a comment we ignore tags etc + checkInsertNewline( + "\n" + + "<!--\n" + + "<foo><^\n" + + "-->\n", + + "\n" + + "<!--\n" + + "<foo><\n" + + "^\n" + + "-->\n"); + } + + public void testSurroundCaret() throws Exception { + checkInsertNewline( + "\n" + + " <item>^</item>\n", + + "\n" + + " <item>\n" + + " ^\n" + + " </item>\n"); + } + + public void testSurroundCaret2() throws Exception { + // This test combines both surround with and continuing earlier lines (where + // it searches for a matching tag) + checkInsertNewline( + "\n" + + " <foo\n" + + " name='value'>^</foo>\n", + + "\n" + + " <foo\n" + + " name='value'>\n" + + " ^\n" + + " </foo>\n"); + } + + public void testContinueEarlierLine1() throws Exception { + // Here we need to indent to the exact location of an earlier line + checkInsertNewline( + "\n" + + " <foo\n" + + " name='value'/>^\n", + + "\n" + + " <foo\n" + + " name='value'/>\n" + + " ^\n"); + } + + public void testContinueEarlierLine2() throws Exception { + checkInsertNewline( + "\n" + + " <foo\n" + + " name='value'></foo>^\n", + + "\n" + + " <foo\n" + + " name='value'></foo>\n" + + " ^\n"); + // Note that + // <foo + // > + // </foo> + // does not require special handling, this only happens with the closing tag is sharing + // a line. + } + + public void testContinueEarlierLine3() throws Exception { + // Make sure the code to look up the corresponding opening tag works properly + checkInsertNewline( + "\n" + + " <foo\n" + + " name='value'><bar></bar><baz/></foo>^\n", + + "\n" + + " <foo\n" + + " name='value'><bar></bar><baz/></foo>\n" + + " ^\n"); + } + + public void testContinueEarlierLine4() throws Exception { + checkInsertNewline( + " <Button\n" + + " android:id=\"@+id/button1\"\n" + + " android:layout_width=\"wrap_content\"\n" + + " android:layout_height=\"wrap_content\"\n" + + " android:text=\"Button\" >^\n" + + " </Button>\n", + + " <Button\n" + + " android:id=\"@+id/button1\"\n" + + " android:layout_width=\"wrap_content\"\n" + + " android:layout_height=\"wrap_content\"\n" + + " android:text=\"Button\" >\n" + + " ^\n" + + " </Button>\n"); + } + + public void testIndent() throws Exception { + checkInsertNewline( + " <Button\n" + + " attr=\"value\"></Button>^\n", + + " <Button\n" + + " attr=\"value\"></Button>\n" + + " ^\n" + + ""); + } + + public void testLineBeginning1() throws Exception { + // Test that if you insert on a blank line, we just add a newline and indent + checkInsertNewline( + "<foo>\n" + + "^\n" + + "</foo>", + + "<foo>\n" + + "\n" + + " ^\n" + + "</foo>"); + } + + public void testLineBeginning2() throws Exception { + // Test that if you insert with the caret on the beginning of a line that has + // content, we insert an indent correctly + checkInsertNewline( + "<foo>\n" + + "^ <bar/>\n" + + "</foo>", + + "<foo>\n" + + "\n" + + " ^<bar/>\n" + + "</foo>"); + } + + public void testLineBeginning3() throws Exception { + checkInsertNewline( + "<foo>\n" + + " <bar>\n" + + "^\n" + + " <baz/>\n" + + " </bar>\n" + + "</foo>", + + "<foo>\n" + + " <bar>\n" + + "\n" + + " ^\n" + + " <baz/>\n" + + " </bar>\n" + + "</foo>"); + + } + + public void testLineBeginning4() throws Exception { + // Test that if you insert with the caret on the beginning of a line that has + // content, we insert an indent correctly + checkInsertNewline( + "<foo>\n" + + " <bar>\n" + + "\n" + + "^ <baz/>\n" + + " </bar>\n" + + "</foo>", + + "<foo>\n" + + " <bar>\n" + + "\n" + + "\n" + + " ^<baz/>\n" + + " </bar>\n" + + "</foo>"); + } + + public void testLineBeginning5() throws Exception { + // Test that if you insert with the caret on the beginning of a line that has + // content, we insert an indent correctly + checkInsertNewline( + "<foo>\n" + + " <bar>\n" + + "\n" + + " ^ <baz/>\n" + + " </bar>\n" + + "</foo>", + + "<foo>\n" + + " <bar>\n" + + "\n" + + " \n" + + " ^<baz/>\n" + + " </bar>\n" + + "</foo>"); + } + + public void testLineBeginning6() throws Exception { + + checkInsertNewline( + " <foo>\n" + + " <bar>\n" + + " \n" + + " \n" + + "^ </bar>\n" + + " </foo>\n", + + " <foo>\n" + + " <bar>\n" + + " \n" + + " \n" + + "\n" + + " ^</bar>\n" + + " </foo>\n"); + } + + public void testBlankContinuation() throws Exception { + + checkInsertNewline( + " <foo>\n" + + " <bar>\n" + + " ^\n" + + " </bar>\n" + + " </foo>\n" + + "", + + " <foo>\n" + + " <bar>\n" + + " \n" + + " ^\n" + + " </bar>\n" + + " </foo>\n" + + ""); + } + + public void testIssue22332a() throws Exception { + checkInsertNewline( + "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + + "<resources>\n" + + "\n" + + " <string name=\"hello\">Hello World, MainActivity!</string>^\n" + + "\n" + + "</resources>", + + "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + + "<resources>\n" + + "\n" + + " <string name=\"hello\">Hello World, MainActivity!</string>\n" + + " ^\n" + + "\n" + + "</resources>"); + } + + public void testIssue22332b() throws Exception { + checkInsertNewline( + "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + + "<resources>\n" + + "\n" + + " <string name=\"hello\">Hello World, MainActivity!</string>\n" + + " ^\n" + + "\n" + + "</resources>", + + "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + + "<resources>\n" + + "\n" + + " <string name=\"hello\">Hello World, MainActivity!</string>\n" + + " \n" + + " ^\n" + + "\n" + + "</resources>"); + } + + /** + * To test + * When you press / after < I should reindent the current line. For example, + * if you have + * <foo> + * <bar> + * </ the moment you've typed this we should dedent it back out + * When you press newline we need to reindent + */ + + /** Subclassed for test usage since constructor is protected */ + private class TestDocumentCommand extends DocumentCommand { + public TestDocumentCommand() { + } + } +} diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/AndroidXmlCharacterMatcherTest.java b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/AndroidXmlCharacterMatcherTest.java new file mode 100644 index 000000000..acb2b049b --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/AndroidXmlCharacterMatcherTest.java @@ -0,0 +1,144 @@ +/* + * 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; + +import com.android.ide.eclipse.adt.internal.editors.layout.refactoring.AdtProjectTest; + +import org.eclipse.core.resources.IFile; +import org.eclipse.jface.text.IRegion; +import org.eclipse.jface.text.source.ISourceViewer; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.ide.IDE; +import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument; + +@SuppressWarnings("restriction") +public class AndroidXmlCharacterMatcherTest extends AdtProjectTest { + public void testGotoMatchingFwd1() throws Exception { + checkGotoMatching( + "<app^lication android:icon", + "^</application>"); + } + + public void testGotoMatchingFwd2() throws Exception { + checkGotoMatching( + "^<application android:icon", + "^</application>"); + } + + public void testGotoMatchingFwd3() throws Exception { + checkGotoMatching( + "<application^ android:icon", + "^</application>"); + } + + public void testGotoMatchingBwd1() throws Exception { + checkGotoMatching( + "^</application>", + "^<application android:icon"); + } + + public void testGotoMatchingBwd2() throws Exception { + checkGotoMatching( + "<^/application>", + "^<application android:icon"); + } + + public void testGotoMatchingBwd3() throws Exception { + checkGotoMatching( + "</^application>", + "^<application android:icon"); + } + + public void testGotoMatchingBwd4() throws Exception { + checkGotoMatching( + "</app^lication>", + "^<application android:icon"); + } + + public void testGotoMatchingBwd5() throws Exception { + checkGotoMatching( + "</^application>", + "^<application android:icon"); + } + + public void testGotoMatchingBwd6() throws Exception { + checkGotoMatching( + "</^application>", + "^<application android:icon"); + } + + public void testGotoMatchingFwd4() throws Exception { + checkGotoMatching( + "<intent-filter^>", + "^</intent-filter>"); + } + + public void testGotoMatchingFwd5() throws Exception { + checkGotoMatching( + "<intent-filter>^", + "^</intent-filter>"); + } + + public void testGotoMatchingFallback() throws Exception { + // Character matching is done by the superclass; ensure that fallback to the + // other XML matchers is working + checkGotoMatching( + "android:icon=^\"@drawable/icon\"", + "android:icon=\"@drawable/icon^\""); + } + + private void checkGotoMatching(IFile file, String caretBefore, + String caretAfter) throws Exception { + IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); + assertNotNull(page); + IEditorPart editor = IDE.openEditor(page, file); + assertTrue(editor instanceof AndroidXmlEditor); + AndroidXmlEditor layoutEditor = (AndroidXmlEditor) editor; + ISourceViewer viewer = layoutEditor.getStructuredSourceViewer(); + + int caretPosBefore = updateCaret(viewer, caretBefore); + + AndroidXmlCharacterMatcher matcher = new AndroidXmlCharacterMatcher(); + IStructuredDocument document = layoutEditor.getStructuredDocument(); + + IRegion match = matcher.match(document, caretPosBefore); + assertNotNull(match); + + String text = document.get(); + final String after = stripCaret(caretAfter); + int index = text.indexOf(after); + int caretPosAfter = match.getOffset() - index; + String textWithCaret = after.substring(0, caretPosAfter) + + "^" + after.substring(caretPosAfter); + + assertEquals(caretAfter, textWithCaret); + } + + private static String stripCaret(String s) { + int index = s.indexOf('^'); + assertTrue(index != -1); + return s.substring(0, index) + s.substring(index + 1); + } + + private void checkGotoMatching(String caretBefore, + String caretAfter) throws Exception { + checkGotoMatching( + getTestDataFile(getProject(), "manifest.xml", "AndroidManifest.xml", true), + caretBefore, caretAfter); + } +} diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/HyperlinksTest.java b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/HyperlinksTest.java new file mode 100644 index 000000000..20aae846b --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/HyperlinksTest.java @@ -0,0 +1,320 @@ +/* + * 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; + +import static com.android.SdkConstants.FD_SOURCES; + +import com.android.ide.common.resources.ResourceFile; +import com.android.ide.eclipse.adt.AdtUtils; +import com.android.ide.eclipse.adt.internal.editors.Hyperlinks.ResourceLink; +import com.android.ide.eclipse.adt.internal.editors.Hyperlinks.XmlResolver; +import com.android.ide.eclipse.adt.internal.editors.layout.refactoring.AdtProjectTest; + +import org.eclipse.core.resources.IFile; +import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor; +import org.eclipse.jface.text.IDocument; +import org.eclipse.jface.text.IRegion; +import org.eclipse.jface.text.Region; +import org.eclipse.jface.text.hyperlink.IHyperlink; +import org.eclipse.jface.text.source.ISourceViewer; +import org.eclipse.swt.graphics.Point; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.ide.IDE; +import org.eclipse.ui.internal.ErrorEditorPart; +import org.eclipse.ui.internal.browser.WebBrowserEditor; +import org.eclipse.wst.sse.ui.StructuredTextEditor; +import org.eclipse.wst.sse.ui.internal.StructuredTextViewer; +import org.eclipse.wst.xml.ui.internal.tabletree.XMLMultiPageEditorPart; + +import java.lang.reflect.Field; +import java.lang.reflect.Method; + +@SuppressWarnings({ + "restriction", "javadoc" +}) +public class HyperlinksTest extends AdtProjectTest { + @Override + protected boolean testCaseNeedsUniqueProject() { + return true; + } + + public void testFqnRegexp() throws Exception { + assertTrue(Hyperlinks.isViewClassName("com.android.Foo")); + assertTrue(Hyperlinks.isViewClassName("com.android.pk_g.Foo_Bar1")); + assertTrue(Hyperlinks.isViewClassName("com.android.Foo$Inner")); + + // Should we allow non-standard packages and class names? + // For now, we're allowing it -- see how this works out in practice. + //assertFalse(XmlHyperlinkResolver.isViewClassName("Foo.bar")); + assertTrue(Hyperlinks.isViewClassName("Foo.bar")); + + assertFalse(Hyperlinks.isViewClassName("LinearLayout")); + assertFalse(Hyperlinks.isViewClassName(".")); + assertFalse(Hyperlinks.isViewClassName(".F")); + assertFalse(Hyperlinks.isViewClassName("f.")); + assertFalse(Hyperlinks.isViewClassName("Foo")); + assertFalse(Hyperlinks.isViewClassName("com.android.1Foo")); + assertFalse(Hyperlinks.isViewClassName("1com.Foo")); + } + + public void testNavigate1() throws Exception { + // Check navigating to a local resource + checkXmlNavigation("navigation1.xml", "res/layout/navigation1.xml", + "android:text=\"@string/app^_name\""); + } + + public void testNavigate2() throws Exception { + // Check navigating to a framework resource + checkXmlNavigation("navigation1.xml", "res/layout/navigation1.xml", + "marginLeft=\"@android:dimen/app_ico^n_size\""); + } + + public void testNavigate3() throws Exception { + // Check navigating to a style + checkXmlNavigation("navigation1.xml", "res/layout/navigation1.xml", + "style=\"@android:style/Widget.B^utton\""); + } + + public void testNavigate4() throws Exception { + // Check navigating to resource with many resolutions + checkXmlNavigation("navigation1.xml", "res/layout/navigation1.xml", + "android:text=\"@android:st^ring/ok\""); + } + + public void testNavigate5() throws Exception { + // Check navigating to styles + checkXmlNavigation("navigationstyles.xml", "res/values/navigationstyles.xml", + "parent=\"android:Theme.Li^ght\">"); + } + + public void testNavigate6() throws Exception { + // Check navigating to a portion of a style (this should pick android:Theme, not + // android:Theme.Light + checkXmlNavigation("navigationstyles.xml", "res/values/navigationstyles.xml", + "parent=\"android:The^me.Light\">"); + } + + public void testNavigate7() throws Exception { + // Check navigating to a resource inside text content + checkXmlNavigation("navigationstyles.xml", "res/values/navigationstyles.xml", + "popupBackground\">@android:drawable/spinner_dr^opdown_background</item>"); + } + + public void testNavigate8() throws Exception { + // Check navigating to a resource inside text content where there is space around + // the URL + checkXmlNavigation("navigationstyles.xml", "res/values/navigationstyles.xml", + "colorBackground\"> @color/cust^om_theme_color </item>"); + } + + public void testNavigate9a() throws Exception { + // Check navigating to a an activity + checkXmlNavigation("manifest.xml", "AndroidManifest.xml", + "<activity android:name=\".Test^Activity\""); + } + + /* Not yet implemented + public void testNavigate9b() throws Exception { + // Check navigating to a an activity - clicking on the activity element should + // work too + checkXmlNavigation("manifest.xml", "AndroidManifest.xml", + "<acti^vity android:name=\".TestActivity\""); + } + */ + + public void testNavigate10() throws Exception { + // Check navigating to a permission + checkXmlNavigation("manifest.xml", "AndroidManifest.xml", + "<uses-permission android:name=\"android.permission.AC^CESS_NETWORK_STATE\" />"); + } + + public void testNavigate11a() throws Exception { + // Check navigating to an intent + checkXmlNavigation("manifest.xml", "AndroidManifest.xml", + "<action android:name=\"android.intent.ac^tion.MAIN\" />"); + } + + public void testNavigate11g() throws Exception { + // Check navigating to an intent + checkXmlNavigation("manifest.xml", "AndroidManifest.xml", + "<category android:name=\"android.intent.category.LA^UNCHER\" />"); + } + + public void testNavigate12() throws Exception { + // Check navigating to a custom view class + checkXmlNavigation("navigation1.xml", "res/layout/navigation1.xml", + "<my.Cust^omView></my.CustomView>"); + } + + public void testNavigate13() throws Exception { + // Check jumping to classes pointed to by fragments + + getTestDataFile(getProject(), "TestFragment.java.txt", + FD_SOURCES + "/" + TEST_PROJECT_PACKAGE.replace('.', '/') + "/TestFragment.java"); + checkXmlNavigation("fragmentlayout.xml", "res/layout/fragmentlayout.xml", + "android:name=\"com.android.ecl^ipse.tests.TestFragment\""); + } + + public void testNavigate14() throws Exception { + // Check jumping to classes pointed to by fragments + + getTestDataFile(getProject(), "TestFragment.java.txt", + FD_SOURCES + "/" + TEST_PROJECT_PACKAGE.replace('.', '/') + "/TestFragment.java"); + checkXmlNavigation("fragmentlayout.xml", "res/layout/fragmentlayout.xml", + "class=\"com.and^roid.eclipse.tests.TestFragment\""); + } + + public void testNavigate15() throws Exception { + // Check navigating to a theme resource + checkXmlNavigation("navigation1.xml", "res/layout/navigation1.xml", + "?android:attr/alert^DialogStyle"); + } + + public void testNavigate16() throws Exception { + // Check navigating to a theme resource + checkXmlNavigation("navigation1.xml", "res/layout/navigation1.xml", + "?android:alert^DialogStyle"); + } + + // Left to test: + // onClick handling + // class attributes + // Test that the correct file is actually opened! + + private void checkXmlNavigation(String basename, String targetPath, + String caretLocation) throws Exception { + IFile file = getTestDataFile(getProject(), basename, targetPath, true); + + // Determine the offset + int offset = getCaretOffset(file, caretLocation); + + // Open file + IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); + assertNotNull(page); + IEditorPart editor = IDE.openEditor(page, file); + assertTrue(editor.getClass().getName(), editor instanceof AndroidXmlEditor); + AndroidXmlEditor layoutEditor = (AndroidXmlEditor) editor; + ISourceViewer viewer = layoutEditor.getStructuredSourceViewer(); + + XmlResolver resolver = new Hyperlinks.XmlResolver(); + IHyperlink[] links = resolver.detectHyperlinks(viewer, new Region(offset, 0), true); + assertNotNull(links); + + StringBuilder sb = new StringBuilder(1000); + sb.append("Go To Declaration in " + basename + " for " + caretLocation + ":\n"); + for (IHyperlink link : links) { + sb.append(link.getHyperlinkText()); + sb.append(" : "); + sb.append(" ["); + IRegion region = link.getHyperlinkRegion(); + sb.append(viewer.getDocument().get(region.getOffset(), region.getLength())); + sb.append("]"); + if (link instanceof Hyperlinks.ResourceLink) { + Hyperlinks.ResourceLink resourceLink = (ResourceLink) link; + sb.append("\n "); + ResourceFile resourceFile = resourceLink.getFile(); + String desc = resourceFile.toString(); + desc = desc.replace('\\', '/'); + // For files in the SDK folder, strip out file prefix + int dataRes = desc.indexOf("data/res"); + if (dataRes != -1) { + desc = desc.substring(dataRes); + } + desc = removeSessionData(desc); + sb.append(desc); + } + sb.append('\n'); + } + + // Open the first link + IHyperlink link = links[0]; + link.open(); + IEditorPart newEditor = AdtUtils.getActiveEditor(); + // Ensure that this isn't an invalid file (e.g. opening the SDK platform files + // with incorrect content binding could cause this) + assertTrue(!(newEditor instanceof ErrorEditorPart)); + + IDocument document = null; + Point selection = null; + + if (newEditor instanceof AndroidXmlEditor) { + AndroidXmlEditor xmlEditor = (AndroidXmlEditor) newEditor; + document = xmlEditor.getStructuredSourceViewer().getDocument(); + selection = xmlEditor.getStructuredSourceViewer().getSelectedRange(); + } else if (newEditor instanceof XMLMultiPageEditorPart) { + XMLMultiPageEditorPart xmlEditor = (XMLMultiPageEditorPart) newEditor; + Field field = xmlEditor.getClass().getDeclaredField("fTextEditor"); + field.setAccessible(true); + StructuredTextEditor ste = (StructuredTextEditor) field.get(newEditor); + if (ste == null) { + Method method = xmlEditor.getClass().getMethod("getTextEditor", new Class[0]); + ste = (StructuredTextEditor) method.invoke(newEditor, new Object[0]); + } + StructuredTextViewer textViewer = ste.getTextViewer(); + document = textViewer.getDocument(); + selection = textViewer.getSelectedRange(); + } else if (newEditor instanceof WebBrowserEditor) { + WebBrowserEditor browser = (WebBrowserEditor) newEditor; + Field field = browser.getClass().getDeclaredField("initialURL"); + field.setAccessible(true); + String initialUrl = (String) field.get(newEditor); + int index = initialUrl.indexOf("reference"); + if (index != -1) { + initialUrl = initialUrl.substring(index); + } + initialUrl = initialUrl.replace('\\', '/'); + sb.append("\n\nAfter open, a browser is shown with this URL:\n"); + sb.append(" "); + sb.append(initialUrl); + sb.append("\n"); + } else if (newEditor instanceof JavaEditor) { + JavaEditor javaEditor = (JavaEditor) newEditor; + document = javaEditor.getDocumentProvider().getDocument(javaEditor.getEditorInput()); + IRegion range = javaEditor.getHighlightRange(); + selection = new Point(range.getOffset(), range.getLength()); + } else { + fail("Unhandled editor type: " + newEditor.getClass().getName()); + return; + } + + if (document != null && selection != null) { + int lineStart = document.getLineInformationOfOffset(selection.x).getOffset(); + IRegion lineEndInfo = document.getLineInformationOfOffset(selection.x + selection.y); + int lineEnd = lineEndInfo.getOffset() + lineEndInfo.getLength(); + String text = document.get(lineStart, lineEnd - lineStart); + int selectionStart = selection.x - lineStart; + int selectionEnd = selectionStart + selection.y; + if (selectionEnd > selectionStart) { + // Selection range + text = text.substring(0, selectionStart) + "[^" + + text.substring(selectionStart, selectionEnd) + "]" + + text.substring(selectionEnd); + } else { + text = text.substring(0, selectionStart) + "^" + + text.substring(selectionStart); + } + text = removeSessionData(text); + + sb.append("\n\nAfter open, the selected text is:\n"); + sb.append(text); + sb.append("\n"); + } + + assertEqualsGolden(basename, sb.toString(), "txt"); + } +} diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/formatting/EclipseXmlPrettyPrinterTest.java b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/formatting/EclipseXmlPrettyPrinterTest.java new file mode 100644 index 000000000..ac5fd0196 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/formatting/EclipseXmlPrettyPrinterTest.java @@ -0,0 +1,978 @@ +/* + * 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.formatting; + +import com.android.ide.common.xml.XmlFormatStyle; +import com.android.ide.eclipse.adt.internal.editors.layout.gle2.DomUtilities; +import com.android.ide.eclipse.adt.internal.preferences.AdtPrefs; + +import org.eclipse.jface.preference.PreferenceStore; +import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel; +import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel; +import org.w3c.dom.Document; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +import junit.framework.TestCase; + +@SuppressWarnings({ + "javadoc", "restriction" +}) +public class EclipseXmlPrettyPrinterTest extends TestCase { + @Override + protected void setUp() throws Exception { + super.setUp(); + PreferenceStore store = new PreferenceStore(); + AdtPrefs.init(store); + AdtPrefs prefs = AdtPrefs.getPrefs(); + prefs.initializeStoreWithDefaults(store); + prefs.loadValues(null); + EclipseXmlFormatPreferences formatPrefs = EclipseXmlFormatPreferences.create(); + assertTrue(formatPrefs.oneAttributeOnFirstLine); + } + + private void checkFormat(EclipseXmlFormatPreferences prefs, String baseLocation, + String xml, + String expected, String delimiter, String startNodeName, + boolean openTagOnly, String endNodeName) throws Exception { + + IStructuredModel model = DomUtilities.createStructuredModel(xml); + assertNotNull(model); + model.setBaseLocation(baseLocation); + Document document = null; + if (model instanceof IDOMModel) { + IDOMModel domModel = (IDOMModel) model; + document = domModel.getDocument(); + } else { + fail("Can't get DOM model"); + return; + } + XmlFormatStyle style = AndroidXmlFormattingStrategy.guessStyle(model, document); + + EclipseXmlPrettyPrinter printer = new EclipseXmlPrettyPrinter(prefs, style, delimiter); + printer.setEndWithNewline(xml.endsWith("\n")); + + StringBuilder sb = new StringBuilder(1000); + Node startNode = document; + Node endNode = document; + if (startNodeName != null) { + startNode = findNode(document.getDocumentElement(), startNodeName); + } + if (endNodeName != null) { + endNode = findNode(document.getDocumentElement(), endNodeName); + } + + printer.prettyPrint(-1, document, startNode, endNode, sb, false/*openTagOnly*/); + String formatted = sb.toString(); + if (!expected.equals(formatted)) { + System.out.println(formatted); + } + assertEquals(expected, formatted); + } + + private Node findNode(Node node, String nodeName) { + if (node.getNodeName().equals(nodeName)) { + return node; + } + + NodeList children = node.getChildNodes(); + for (int i = 0, n = children.getLength(); i < n; i++) { + Node child = children.item(i); + Node result = findNode(child, nodeName); + if (result != null) { + return result; + } + } + + return null; + } + + protected int getCaretOffset(String fileContent, String caretLocation) { + int caretDelta = caretLocation.indexOf("^"); //$NON-NLS-1$ + assertTrue(caretLocation, caretDelta != -1); + + String caretContext = caretLocation.substring(0, caretDelta) + + caretLocation.substring(caretDelta + 1); // +1: skip "^" + int caretContextIndex = fileContent.indexOf(caretContext); + assertTrue("Caret content " + caretContext + " not found in file", + caretContextIndex != -1); + return caretContextIndex + caretDelta; + } + + private void checkFormat(EclipseXmlFormatPreferences prefs, String baseLocation, String xml, + String expected, String delimiter) throws Exception { + checkFormat(prefs, baseLocation, xml, expected, delimiter, null, false, null); + } + + private void checkFormat(EclipseXmlFormatPreferences prefs, String baseLocation, String xml, + String expected) throws Exception { + checkFormat(prefs, baseLocation, xml, expected, "\n"); //$NON-NLS-1$ + } + private void checkFormat(String baseLocation, String xml, String expected) + throws Exception { + EclipseXmlFormatPreferences prefs = EclipseXmlFormatPreferences.create(); + checkFormat(prefs, baseLocation, xml, expected); + } + + public void testLayout1() throws Exception { + checkFormat( + "res/layout-port/layout1.xml", + "<LinearLayout><Button></Button></LinearLayout>", + + "<LinearLayout>\n" + + "\n" + + " <Button>\n" + + " </Button>\n" + + "\n" + + "</LinearLayout>"); + } + + public void testLayout2() throws Exception { + checkFormat( + "res/layout-port/layout2.xml", + "<LinearLayout><Button foo=\"bar\"></Button></LinearLayout>", + + "<LinearLayout>\n" + + "\n" + + " <Button foo=\"bar\" >\n" + + " </Button>\n" + + "\n" + + "</LinearLayout>"); + } + + public void testLayout3() throws Exception { + EclipseXmlFormatPreferences prefs = EclipseXmlFormatPreferences.create(); + prefs.oneAttributeOnFirstLine = true; + checkFormat( + prefs, "res/layout-land/layout3.xml", + "<LinearLayout><Button foo=\"bar\"></Button></LinearLayout>", + + "<LinearLayout>\n" + + "\n" + + " <Button foo=\"bar\" >\n" + + " </Button>\n" + + "\n" + + "</LinearLayout>"); + } + + public void testClosedElements() throws Exception { + checkFormat( + "res/values/strings.xml", + "<resources>\n" + + "<item name=\"title_container\" type=\"id\" />\n" + + "<item name=\"title_logo\" type=\"id\"/>\n" + + "</resources>\n", + + "<resources>\n" + + "\n" + + " <item name=\"title_container\" type=\"id\"/>\n" + + " <item name=\"title_logo\" type=\"id\"/>\n" + + "\n" + + "</resources>\n"); + } + + public void testResources() throws Exception { + checkFormat( + "res/values-us/strings.xml", + "<resources><item name=\"foo\">Text value here </item></resources>", + "<resources>\n\n" + + " <item name=\"foo\">Text value here </item>\n" + + "\n</resources>"); + } + + public void testNodeTypes() throws Exception { + // Ensures that a document with all kinds of node types is serialized correctly + checkFormat( + "res/layout-xlarge/layout.xml", + "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + + "<!--\n" + + "/**\n" + + " * Licensed under the Apache License, Version 2.0 (the \"License\");\n" + + " */\n" + + "-->\n" + + "<!DOCTYPE metadata [\n" + + "<!ELEMENT metadata (category)*>\n" + + "<!ENTITY % ISOLat2\n" + + " SYSTEM \"http://www.xml.com/iso/isolat2-xml.entities\" >\n" + + "]>\n" + + "<LinearLayout\n" + + " xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" + + " android:orientation=\"vertical\">\n" + + "<![CDATA[\n" + + "This is character data!\n" + + "<!-- This is not a comment! -->\n" + + "and <this is not an element>\n" + + "]]> \n" + + "This is text: < and &\n" + + "<!-- comment 1 \"test\"... -->\n" + + "<!-- ... comment2 -->\n" + + "%ISOLat2; \n" + + "<!-- \n" + + "Type <key>less-than</key> (<)\n" + + "--> \n" + + "</LinearLayout>", + + "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + + "<!--\n" + + "/**\n" + + " * Licensed under the Apache License, Version 2.0 (the \"License\");\n" + + " */\n" + + "-->\n" + + "<!DOCTYPE metadata [\n" + + "<!ELEMENT metadata (category)*>\n" + + "<!ENTITY % ISOLat2\n" + + " SYSTEM \"http://www.xml.com/iso/isolat2-xml.entities\" >\n" + + "]>\n" + + "<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" + + " android:orientation=\"vertical\" >\n" + + "<![CDATA[\n" + + "This is character data!\n" + + "<!-- This is not a comment! -->\n" + + "and <this is not an element>\n" + + "]]>\n" + + "This is text: < and &\n" + + " <!-- comment 1 \"test\"... -->\n" + + " <!-- ... comment2 -->\n" + + "%ISOLat2; \n" + + "<!-- Type <key>less-than</key> (<) -->\n" + + "\n" + + "</LinearLayout>"); + } + + public void testWindowsDelimiters() throws Exception { + checkFormat( + EclipseXmlFormatPreferences.create(), "res/layout-xlarge/layout.xml", + "<LinearLayout><Button foo=\"bar\"></Button></LinearLayout>", + + "<LinearLayout>\r\n" + + "\r\n" + + " <Button foo=\"bar\" >\r\n" + + " </Button>\r\n" + + "\r\n" + + "</LinearLayout>", + "\r\n"); + } + + public void testRemoveBlanklines() throws Exception { + EclipseXmlFormatPreferences prefs = EclipseXmlFormatPreferences.create(); + prefs.removeEmptyLines = true; + checkFormat( + prefs, "res/layout-xlarge/layout.xml", + "<foo><bar><baz1></baz1><baz2></baz2></bar><bar2></bar2><bar3><baz12></baz12></bar3></foo>", + + "<foo>\n" + + " <bar>\n" + + " <baz1>\n" + + " </baz1>\n" + + " <baz2>\n" + + " </baz2>\n" + + " </bar>\n" + + " <bar2>\n" + + " </bar2>\n" + + " <bar3>\n" + + " <baz12>\n" + + " </baz12>\n" + + " </bar3>\n" + + "</foo>"); + } + + public void testRange() throws Exception { + checkFormat( + EclipseXmlFormatPreferences.create(), "res/layout-xlarge/layout.xml", + "<LinearLayout><Button foo=\"bar\"></Button><CheckBox/></LinearLayout>", + "\n" + + " <Button foo=\"bar\" >\n" + + " </Button>\n" + + "\n" + + " <CheckBox />\n", + "\n", + "Button", false, "CheckBox"); + } + + public void testOpenTagOnly() throws Exception { + checkFormat( + EclipseXmlFormatPreferences.create(), "res/layout-xlarge/layout.xml", + "<LinearLayout><Button foo=\"bar\"></Button><CheckBox/></LinearLayout>", + "\n" + + " <Button foo=\"bar\" >\n" + + " </Button>\n", + "\n", + + "Button", true, "Button"); + } + + public void testRange2() throws Exception { + EclipseXmlFormatPreferences prefs = EclipseXmlFormatPreferences.create(); + prefs.removeEmptyLines = true; + checkFormat( + prefs, "res/layout-xlarge/layout.xml", + "<foo><bar><baz1></baz1><baz2></baz2></bar><bar2></bar2><bar3><baz12></baz12></bar3></foo>", + + " <baz1>\n" + + " </baz1>\n" + + " <baz2>\n" + + " </baz2>\n" + + " </bar>\n" + + " <bar2>\n" + + " </bar2>\n" + + " <bar3>\n" + + " <baz12>\n" + + " </baz12>\n", + "\n", + "baz1", false, "baz12"); + } + + public void testEOLcomments() throws Exception { + checkFormat( + "res/drawable-mdpi/states.xml", + "<selector xmlns:android=\"http://schemas.android.com/apk/res/android\">\n" + + " <item android:state_pressed=\"true\"\n" + + " android:color=\"#ffff0000\"/> <!-- pressed -->\n" + + " <item android:state_focused=\"true\"\n" + + " android:color=\"#ff0000ff\"/> <!-- focused -->\n" + + " <item android:color=\"#ff000000\"/> <!-- default -->\n" + + "</selector>", + "<selector xmlns:android=\"http://schemas.android.com/apk/res/android\">\n" + + "\n" + + " <item android:state_pressed=\"true\" android:color=\"#ffff0000\"/> <!-- pressed -->\n" + + " <item android:state_focused=\"true\" android:color=\"#ff0000ff\"/> <!-- focused -->\n" + + " <item android:color=\"#ff000000\"/> <!-- default -->\n" + + "\n" + + "</selector>"); + } + + public void testFormatColorList() throws Exception { + checkFormat( + "res/drawable-hdpi/states.xml", + "<selector xmlns:android=\"http://schemas.android.com/apk/res/android\">\n" + + "<item android:state_activated=\"true\" android:color=\"#FFFFFF\"/>\n" + + "<item android:color=\"#777777\" /> <!-- not selected -->\n" + + "</selector>", + "<selector xmlns:android=\"http://schemas.android.com/apk/res/android\">\n" + + "\n" + + " <item android:state_activated=\"true\" android:color=\"#FFFFFF\"/>\n" + + " <item android:color=\"#777777\"/> <!-- not selected -->\n" + + "\n" + + "</selector>"); + } + + public void testPreserveNewlineAfterComment() throws Exception { + checkFormat( + "res/values/dimen.xml", + "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + + "<resources><dimen name=\"colorstrip_height\">6dip</dimen>\n" + + " <!-- comment1 --><dimen name=\"title_height\">45dip</dimen>\n" + + "\n" + + " <!-- comment2: newline above --><dimen name=\"now_playing_height\">90dip</dimen>\n" + + " <dimen name=\"text_size_small\">14sp</dimen>\n" + + "\n" + + "\n" + + " <!-- comment3: newline above and below -->\n" + + "\n" + + "\n" + + "\n" + + " <dimen name=\"text_size_medium\">18sp</dimen><dimen name=\"text_size_large\">22sp</dimen>\n" + + "</resources>", + "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + + "<resources>\n" + + "\n" + + " <dimen name=\"colorstrip_height\">6dip</dimen>\n" + + " <!-- comment1 -->\n" + + " <dimen name=\"title_height\">45dip</dimen>\n" + + "\n" + + " <!-- comment2: newline above -->\n" + + " <dimen name=\"now_playing_height\">90dip</dimen>\n" + + " <dimen name=\"text_size_small\">14sp</dimen>\n" + + "\n" + + " <!-- comment3: newline above and below -->\n" + + "\n" + + " <dimen name=\"text_size_medium\">18sp</dimen>\n" + + " <dimen name=\"text_size_large\">22sp</dimen>\n" + + "\n" + + "</resources>"); + } + + public void testPlurals() throws Exception { + checkFormat( + "res/values-us/strings.xml", + "<resources xmlns:xliff=\"urn:oasis:names:tc:xliff:document:1.2\">\n" + + "<string name=\"toast_sync_error\">Sync error: <xliff:g id=\"error\">%1$s</xliff:g></string>\n" + + "<string name=\"session_subtitle\"><xliff:g id=\"time\">%1$s</xliff:g> in <xliff:g id=\"room\">%2$s</xliff:g></string>\n" + + "<plurals name=\"now_playing_countdown\">\n" + + "<item quantity=\"zero\"><xliff:g id=\"remaining_time\">%2$s</xliff:g></item>\n" + + "<item quantity=\"one\"><xliff:g id=\"number_of_days\">%1$s</xliff:g> day, <xliff:g id=\"remaining_time\">%2$s</xliff:g></item>\n" + + "<item quantity=\"other\"><xliff:g id=\"number_of_days\">%1$s</xliff:g> days, <xliff:g id=\"remaining_time\">%2$s</xliff:g></item>\n" + + "</plurals>\n" + + "</resources>", + "<resources xmlns:xliff=\"urn:oasis:names:tc:xliff:document:1.2\">\n" + + "\n" + + " <string name=\"toast_sync_error\">Sync error: <xliff:g id=\"error\">%1$s</xliff:g></string>\n" + + " <string name=\"session_subtitle\"><xliff:g id=\"time\">%1$s</xliff:g> in <xliff:g id=\"room\">%2$s</xliff:g></string>\n" + + "\n" + + " <plurals name=\"now_playing_countdown\">\n" + + " <item quantity=\"zero\"><xliff:g id=\"remaining_time\">%2$s</xliff:g></item>\n" + + " <item quantity=\"one\"><xliff:g id=\"number_of_days\">%1$s</xliff:g> day, <xliff:g id=\"remaining_time\">%2$s</xliff:g></item>\n" + + " <item quantity=\"other\"><xliff:g id=\"number_of_days\">%1$s</xliff:g> days, <xliff:g id=\"remaining_time\">%2$s</xliff:g></item>\n" + + " </plurals>\n" + + "\n" + + "</resources>"); + } + + public void testMultiAttributeResource() throws Exception { + checkFormat( + "res/values-us/strings.xml", + "<resources><string name=\"debug_enable_debug_logging_label\" translatable=\"false\">Enable extra debug logging?</string></resources>", + "<resources>\n" + + "\n" + + " <string name=\"debug_enable_debug_logging_label\" translatable=\"false\">Enable extra debug logging?</string>\n" + + "\n" + + "</resources>"); + } + + public void testMultilineCommentAlignment() throws Exception { + checkFormat( + "res/values-us/strings.xml", + "<resources>" + + " <!-- Deprecated strings - Move the identifiers to this section, mark as DO NOT TRANSLATE,\n" + + " and remove the actual text. These will be removed in a bulk operation. -->\n" + + " <!-- Do Not Translate. Unused string. -->\n" + + " <string name=\"meeting_invitation\"></string>\n" + + "</resources>", + "<resources>\n" + + "\n" + + " <!--\n" + + " Deprecated strings - Move the identifiers to this section, mark as DO NOT TRANSLATE,\n" + + " and remove the actual text. These will be removed in a bulk operation.\n" + + " -->\n" + + " <!-- Do Not Translate. Unused string. -->\n" + + " <string name=\"meeting_invitation\"></string>\n" + + "\n" + + "</resources>"); + } + + public void testLineCommentSpacing() throws Exception { + checkFormat( + "res/values-us/strings.xml", + "<resources>\n" + + "\n" + + " <dimen name=\"colorstrip_height\">6dip</dimen>\n" + + " <!-- comment1 -->\n" + + " <dimen name=\"title_height\">45dip</dimen>\n" + + " <!-- comment2: no newlines -->\n" + + " <dimen name=\"now_playing_height\">90dip</dimen>\n" + + " <dimen name=\"text_size_small\">14sp</dimen>\n" + + "\n" + + " <!-- comment3: newline above and below -->\n" + + "\n" + + " <dimen name=\"text_size_medium\">18sp</dimen>\n" + + " <dimen name=\"text_size_large\">22sp</dimen>\n" + + "\n" + + "</resources>", + + "<resources>\n" + + "\n" + + " <dimen name=\"colorstrip_height\">6dip</dimen>\n" + + " <!-- comment1 -->\n" + + " <dimen name=\"title_height\">45dip</dimen>\n" + + " <!-- comment2: no newlines -->\n" + + " <dimen name=\"now_playing_height\">90dip</dimen>\n" + + " <dimen name=\"text_size_small\">14sp</dimen>\n" + + "\n" + + " <!-- comment3: newline above and below -->\n" + + "\n" + + " <dimen name=\"text_size_medium\">18sp</dimen>\n" + + " <dimen name=\"text_size_large\">22sp</dimen>\n" + + "\n" + + "</resources>"); + } + + public void testCommentHandling() throws Exception { + checkFormat( + EclipseXmlFormatPreferences.create(), "res/layout/layout1.xml", + "<foo >\n" + + "\n" + + " <!-- abc\n" + + " def\n" + + " ghi -->\n" + + "\n" + + " <!-- abc\n" + + " def\n" + + " ghi -->\n" + + " \n" + + "<!-- abc\n" + + "def\n" + + "ghi -->\n" + + "\n" + + "</foo>", + + "<foo>\n" + + "\n" + + " <!--\n" + + " abc\n" + + " def\n" + + " ghi\n" + + " -->\n" + + "\n" + + "\n" + + " <!--\n" + + " abc\n" + + " def\n" + + " ghi\n" + + " -->\n" + + "\n" + + "\n" + + " <!--\n" + + "abc\n" + + "def\n" + + "ghi\n" + + " -->\n" + + "\n" + + "</foo>"); + } + + public void testCommentHandling2() throws Exception { + checkFormat( + EclipseXmlFormatPreferences.create(), "res/layout-xlarge/layout.xml", + "<foo >\n" + + " <!-- multi -->\n" + + "\n" + + " <bar />\n" + + "</foo>", + + "<foo>\n" + + "\n" + + " <!-- multi -->\n" + + "\n" + + " <bar />\n" + + "\n" + + "</foo>"); + } + + public void testMenus1() throws Exception { + checkFormat( + EclipseXmlFormatPreferences.create(), "res/menu/menu1.xml", + // http://code.google.com/p/android/issues/detail?id=21383 + "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + + "<menu xmlns:android=\"http://schemas.android.com/apk/res/android\" >\n" + + "\n" + + " <item\n" + + " android:id=\"@+id/menu_debug\"\n" + + " android:icon=\"@android:drawable/ic_menu_more\"\n" + + " android:showAsAction=\"ifRoom|withText\"\n" + + " android:title=\"@string/menu_debug\">\n" + + " \n" + + " <menu>\n" + + " <item\n" + + " android:id=\"@+id/menu_debug_clearCache_memory\"\n" + + " android:icon=\"@android:drawable/ic_menu_delete\"\n" + + " android:showAsAction=\"ifRoom|withText\"\n" + + " android:title=\"@string/menu_debug_clearCache_memory\"/>\n" + + " \n" + + " <item\n" + + " android:id=\"@+id/menu_debug_clearCache_file\"\n" + + " android:icon=\"@android:drawable/ic_menu_delete\"\n" + + " android:showAsAction=\"ifRoom|withText\"\n" + + " android:title=\"@string/menu_debug_clearCache_file\"/>\n" + + " </menu>\n" + + " </item>\n" + + "</menu>", + + "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + + "<menu xmlns:android=\"http://schemas.android.com/apk/res/android\" >\n" + + "\n" + + " <item\n" + + " android:id=\"@+id/menu_debug\"\n" + + " android:icon=\"@android:drawable/ic_menu_more\"\n" + + " android:showAsAction=\"ifRoom|withText\"\n" + + " android:title=\"@string/menu_debug\">\n" + + " <menu>\n" + + " <item\n" + + " android:id=\"@+id/menu_debug_clearCache_memory\"\n" + + " android:icon=\"@android:drawable/ic_menu_delete\"\n" + + " android:showAsAction=\"ifRoom|withText\"\n" + + " android:title=\"@string/menu_debug_clearCache_memory\"/>\n" + + " <item\n" + + " android:id=\"@+id/menu_debug_clearCache_file\"\n" + + " android:icon=\"@android:drawable/ic_menu_delete\"\n" + + " android:showAsAction=\"ifRoom|withText\"\n" + + " android:title=\"@string/menu_debug_clearCache_file\"/>\n" + + " </menu>\n" + + " </item>\n" + + "\n" + + "</menu>"); + } + + public void testMenus2() throws Exception { + EclipseXmlFormatPreferences prefs = EclipseXmlFormatPreferences.create(); + prefs.removeEmptyLines = true; + checkFormat( + prefs, "res/drawable-hdpi/layerlist.xml", + // http://code.google.com/p/android/issues/detail?id=21346 + "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + + "<layer-list xmlns:android=\"http://schemas.android.com/apk/res/android\">\n" + + " <item>\n" + + " <shape android:shape=\"rectangle\">\n" + + " <stroke\n" + + " android:width=\"1dip\"\n" + + " android:color=\"@color/line_separator\"/>\n" + + " <solid android:color=\"@color/event_header_background\"/>\n" + + " </shape>\n" + + " </item>\n" + + " <item\n" + + " android:bottom=\"1dip\"\n" + + " android:top=\"1dip\">\n" + + " <shape android:shape=\"rectangle\">\n" + + " <stroke\n" + + " android:width=\"1dip\"\n" + + " android:color=\"@color/event_header_background\"/>\n" + + " <solid android:color=\"@color/transparent\"/>\n" + + " </shape>\n" + + " </item>\n" + + "</layer-list>", + + "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + + "<layer-list xmlns:android=\"http://schemas.android.com/apk/res/android\" >\n" + + " <item>\n" + + " <shape android:shape=\"rectangle\" >\n" + + " <stroke\n" + + " android:width=\"1dip\"\n" + + " android:color=\"@color/line_separator\" />\n" + + " <solid android:color=\"@color/event_header_background\" />\n" + + " </shape>\n" + + " </item>\n" + + " <item\n" + + " android:bottom=\"1dip\"\n" + + " android:top=\"1dip\">\n" + + " <shape android:shape=\"rectangle\" >\n" + + " <stroke\n" + + " android:width=\"1dip\"\n" + + " android:color=\"@color/event_header_background\" />\n" + + " <solid android:color=\"@color/transparent\" />\n" + + " </shape>\n" + + " </item>\n" + + "</layer-list>"); + } + + public void testMenus3() throws Exception { + checkFormat( + EclipseXmlFormatPreferences.create(), "res/menu/menu1.xml", + // http://code.google.com/p/android/issues/detail?id=21227 + "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + + "<menu xmlns:android=\"http://schemas.android.com/apk/res/android\" >\n" + + "\n" + + " <item\n" + + " android:icon=\"@android:drawable/ic_menu_more\"\n" + + " android:title=\"@string/account_list_menu_more\">\n" + + " <menu>\n" + + " <item\n" + + " android:id=\"@+id/account_list_menu_backup_restore\"\n" + + " android:icon=\"@android:drawable/ic_menu_save\"\n" + + " android:title=\"@string/account_list_menu_backup_restore\"/>\n" + + " </menu>\n" + + " </item>\n" + + "\n" + + "</menu>", + + "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + + "<menu xmlns:android=\"http://schemas.android.com/apk/res/android\" >\n" + + "\n" + + " <item\n" + + " android:icon=\"@android:drawable/ic_menu_more\"\n" + + " android:title=\"@string/account_list_menu_more\">\n" + + " <menu>\n" + + " <item\n" + + " android:id=\"@+id/account_list_menu_backup_restore\"\n" + + " android:icon=\"@android:drawable/ic_menu_save\"\n" + + " android:title=\"@string/account_list_menu_backup_restore\"/>\n" + + " </menu>\n" + + " </item>\n" + + "\n" + + "</menu>"); + + } + + public void testColors1() throws Exception { + checkFormat( + EclipseXmlFormatPreferences.create(), "res/values/colors.xml", + "<resources>\n" + + " <color name=\"enrollment_error\">#99e21f14</color>\n" + + "\n" + + " <color name=\"service_starting_up\">#99000000</color>\n" + + "</resources>", + + "<resources>\n" + + "\n" + + " <color name=\"enrollment_error\">#99e21f14</color>\n" + + " <color name=\"service_starting_up\">#99000000</color>\n" + + "\n" + + "</resources>"); + } + + public void testEclipseFormatStyle1() throws Exception { + EclipseXmlFormatPreferences prefs = new EclipseXmlFormatPreferences() { + @Override + public String getOneIndentUnit() { + return "\t"; + } + + @Override + public int getTabWidth() { + return 8; + } + }; + checkFormat( + prefs, "res/values/colors.xml", + "<resources>\n" + + " <color name=\"enrollment_error\">#99e21f14</color>\n" + + "\n" + + " <color name=\"service_starting_up\">#99000000</color>\n" + + "</resources>", + + "<resources>\n" + + "\n" + + "\t<color name=\"enrollment_error\">#99e21f14</color>\n" + + "\t<color name=\"service_starting_up\">#99000000</color>\n" + + "\n" + + "</resources>"); + } + + public void testEclipseFormatStyle2() throws Exception { + EclipseXmlFormatPreferences prefs = new EclipseXmlFormatPreferences() { + @Override + public String getOneIndentUnit() { + return " "; + } + + @Override + public int getTabWidth() { + return 2; + } + }; + prefs.useEclipseIndent = true; + checkFormat( + prefs, "res/values/colors.xml", + "<resources>\n" + + " <color name=\"enrollment_error\">#99e21f14</color>\n" + + "\n" + + " <color name=\"service_starting_up\">#99000000</color>\n" + + "</resources>", + + "<resources>\n" + + "\n" + + " <color name=\"enrollment_error\">#99e21f14</color>\n" + + " <color name=\"service_starting_up\">#99000000</color>\n" + + "\n" + + "</resources>"); + } + + public void testNameSorting() throws Exception { + checkFormat( + "res/values/dimen.xml", + "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + + "<resources>\n" + + " <attr format=\"integer\" name=\"no\" />\n" + + "</resources>", + + "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + + "<resources>\n" + + "\n" + + " <attr name=\"no\" format=\"integer\" />\n" + + "\n" + + "</resources>"); + } + + public void testStableText() throws Exception { + checkFormat( + "res/layout/stable.xml", + "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + + "<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" + + " android:layout_width=\"match_parent\"\n" + + " android:layout_height=\"match_parent\"\n" + + " android:orientation=\"vertical\">\n" + + " Hello World\n" + + "\n" + + "</LinearLayout>", + + "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + + "<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" + + " android:layout_width=\"match_parent\"\n" + + " android:layout_height=\"match_parent\"\n" + + " android:orientation=\"vertical\" >\n" + + " Hello World\n" + + "\n" + + "</LinearLayout>"); + } + + public void testResources1() throws Exception { + checkFormat( + "res/values/strings.xml", + "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + + "<resources>\n" + + "\n" + + " <string name=\"test_string\">a\n" + + " </string>\n" + + "\n" + + "</resources>", + + "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + + "<resources>\n" + + "\n" + + " <string name=\"test_string\">a</string>\n" + + "\n" + + "</resources>"); + } + + public void testMarkup() throws Exception { + checkFormat( + "res/values/strings.xml", + "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + + "<resources>\n" + + "\n" + + "<string name=\"welcome\">Welcome to <b>Android</b>!</string>" + + "<string name=\"glob_settings_top_text\"><b>To install a 24 Clock Widget, " + + "please <i>long press</i> in Home Screen.</b> Configure the Global Settings " + + "here.</string>" + + "" + + "\n" + + "</resources>", + + "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + + "<resources>\n" + + "\n" + + " <string name=\"welcome\">Welcome to <b>Android</b>!</string>\n" + + " <string name=\"glob_settings_top_text\"><b>To install a 24 Clock Widget, " + + "please <i>long press</i> in Home Screen.</b> Configure the Global Settings " + + "here.</string>\n" + + "\n" + + "</resources>"); + } + + public void testPreserveEntities() throws Exception { + // Ensure that entities such as > in the input string are preserved in the output + // format + checkFormat( + "res/values/strings.xml", + "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + + "<resources><string name=\"untitled\"><untitled2></string>\n" + + "<string name=\"untitled2\"><untitled2></string>\n" + + "<string name=\"untitled3\">'untitled3"</string></resources>\n", + + "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + + "<resources>\n" + + "\n" + + " <string name=\"untitled\"><untitled2></string>\n" + + " <string name=\"untitled2\"><untitled2></string>\n" + + " <string name=\"untitled3\">'untitled3"</string>\n" + + "\n" + + "</resources>\n"); + } + + public void testCData1() throws Exception { + checkFormat( + "res/values/strings.xml", + "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + + "<resources>\n" + + " <string name=\"foo\"><![CDATA[bar]]></string>\n" + + "</resources>", + + "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + + "<resources>\n" + + "\n" + + " <string name=\"foo\"><![CDATA[bar]]></string>\n" + + "\n" + + "</resources>"); + } + + public void testCData2() throws Exception { + checkFormat( + "res/values/strings.xml", + "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + + "<resources>\n" + + " <string name=\"foo1\"><![CDATA[bar1\n" + + "bar2\n" + + "bar3]]></string>\n" + + " <string name=\"foo2\"><![CDATA[bar]]></string>\n" + + "</resources>", + + "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + + "<resources>\n" + + "\n" + + " <string name=\"foo1\">\n" + + "<![CDATA[bar1\n" + + "bar2\n" + + "bar3]]>\n" + + " </string>\n" + + " <string name=\"foo2\"><![CDATA[bar]]></string>\n" + + "\n" + + "</resources>"); + } + + public void testComplexString() throws Exception { + checkFormat( + "res/values/strings.xml", + "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + + "<resources>\n" + + "<string name=\"progress_completed_export_all\">The database has " + + "<b>successfully</b> been exported into: <br /><br /><font size=\"14\">" + + "\\\"<i>%s</i>\\\"</font></string>" + + "</resources>", + + "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + + "<resources>\n" + + "\n" + + " <string name=\"progress_completed_export_all\">The database has " + + "<b>successfully</b> been exported into: <br /><br /><font size=\"14\">" + + "\\\"<i>%s</i>\\\"</font></string>\n" + + "\n" + + "</resources>"); + } + + public void test52887() throws Exception { + // https://code.google.com/p/android/issues/detail?id=52887 + checkFormat( + "res/layout/relative.xml", + + "<!--Comment-->\n" + + "<RelativeLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" + + " android:layout_width=\"match_parent\"\n" + + " android:layout_height=\"match_parent\"/>\n", + + "<!-- Comment -->\n" + + "<RelativeLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" + + " android:layout_width=\"match_parent\"\n" + + " android:layout_height=\"match_parent\" />\n"); + } + + public void testPreserveLastNewline() throws Exception { + checkFormat( + "res/values/strings.xml", + "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + + "<resources>\n" + + "<string name=\"progress_completed_export_all\">The database has " + + "<b>successfully</b> been exported into: <br /><br /><font size=\"14\">" + + "\\\"<i>%s</i>\\\"</font></string>" + + "</resources>\n", + + "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + + "<resources>\n" + + "\n" + + " <string name=\"progress_completed_export_all\">The database has " + + "<b>successfully</b> been exported into: <br /><br /><font size=\"14\">" + + "\\\"<i>%s</i>\\\"</font></string>\n" + + "\n" + + "</resources>\n"); + } +} diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/LayoutMetadataTest.java b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/LayoutMetadataTest.java new file mode 100644 index 000000000..c71064eba --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/LayoutMetadataTest.java @@ -0,0 +1,109 @@ +/* + * 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.gle2; + +import static com.android.SdkConstants.ATTR_ID; +import static com.android.SdkConstants.ID_PREFIX; +import static com.android.SdkConstants.NEW_ID_PREFIX; +import static com.android.SdkConstants.TOOLS_PREFIX; +import static com.android.SdkConstants.TOOLS_URI; + +import com.android.ide.common.layout.BaseLayoutRule; +import com.android.ide.eclipse.adt.AdtPlugin; +import com.android.ide.eclipse.adt.AdtUtils; +import com.android.ide.eclipse.adt.internal.editors.AndroidXmlEditor; +import com.android.ide.eclipse.adt.internal.editors.layout.refactoring.AdtProjectTest; +import com.android.ide.eclipse.adt.internal.editors.uimodel.UiElementNode; +import com.android.utils.Pair; +import com.android.utils.XmlUtils; + +import org.eclipse.core.resources.IFile; +import org.eclipse.jface.text.IDocument; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.PartInitException; +import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion; +import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument; +import org.w3c.dom.Element; +import org.w3c.dom.Node; + +/** + * + */ +@SuppressWarnings({"restriction", "javadoc", "deprecation"}) // XML DOM model +public class LayoutMetadataTest extends AdtProjectTest { + + public void testMetadata1() throws Exception { + Pair<IDocument, UiElementNode> pair = getNode("metadata.xml", "listView1"); + UiElementNode uiNode = pair.getSecond(); + Node node = uiNode.getXmlNode(); + + assertNull(LayoutMetadata.getProperty(node, "foo")); + + Element element = (Element) node; + String prefix = XmlUtils.lookupNamespacePrefix(element, TOOLS_URI, null, false); + if (prefix == null) { + // Add in new prefix... + prefix = XmlUtils.lookupNamespacePrefix(element, + TOOLS_URI, TOOLS_PREFIX, true); + } + element.setAttribute(prefix + ':' + "foo", "bar"); + } + + // ==== Test utilities ==== + + private static String getText(IDocument document, Node node) throws Exception { + IndexedRegion region = (IndexedRegion) node; + // This often returns the wrong value: + //int length = region.getLength(); + int length = region.getEndOffset() - region.getStartOffset(); + return document.get(region.getStartOffset(), length); + } + + private Pair<IDocument, UiElementNode> getNode(String filename, String targetId) + throws Exception, PartInitException { + IFile file = getLayoutFile(getProject(), filename); + AdtPlugin.openFile(file, null); + IEditorPart newEditor = AdtUtils.getActiveEditor(); + assertTrue(newEditor instanceof AndroidXmlEditor); + AndroidXmlEditor xmlEditor = (AndroidXmlEditor) newEditor; + IStructuredDocument document = xmlEditor.getStructuredDocument(); + UiElementNode root = xmlEditor.getUiRootNode(); + assertNotNull(root); + UiElementNode node = findById(root, targetId); + assertNotNull(node); + Pair<IDocument, UiElementNode> pair = Pair.<IDocument, UiElementNode>of(document, node); + return pair; + } + + private static UiElementNode findById(UiElementNode node, String targetId) { + assertFalse(targetId.startsWith(NEW_ID_PREFIX)); + assertFalse(targetId.startsWith(ID_PREFIX)); + + String id = node.getAttributeValue(ATTR_ID); + if (id != null && targetId.equals(BaseLayoutRule.stripIdPrefix(id))) { + return node; + } + + for (UiElementNode child : node.getUiChildren()) { + UiElementNode result = findById(child, targetId); + if (result != null) { + return result; + } + } + + return null; + } +} diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/AdtProjectTest.java b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/AdtProjectTest.java new file mode 100644 index 000000000..9c48ccdad --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/AdtProjectTest.java @@ -0,0 +1,495 @@ +/* + * 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.refactoring; + +import static com.android.SdkConstants.FD_RES; +import static com.android.SdkConstants.FD_RES_LAYOUT; +import static com.android.SdkConstants.FD_RES_VALUES; + +import com.android.ide.common.sdk.LoadStatus; +import com.android.ide.eclipse.adt.AdtPlugin; +import com.android.ide.eclipse.adt.AdtUtils; +import com.android.ide.eclipse.adt.internal.editors.common.CommonXmlEditor; +import com.android.ide.eclipse.adt.internal.editors.descriptors.AttributeDescriptor; +import com.android.ide.eclipse.adt.internal.editors.descriptors.ElementDescriptor; +import com.android.ide.eclipse.adt.internal.editors.layout.LayoutEditorDelegate; +import com.android.ide.eclipse.adt.internal.editors.layout.descriptors.LayoutDescriptors; +import com.android.ide.eclipse.adt.internal.editors.layout.descriptors.ViewElementDescriptor; +import com.android.ide.eclipse.adt.internal.editors.layout.uimodel.UiViewElementNode; +import com.android.ide.eclipse.adt.internal.editors.uimodel.UiDocumentNode; +import com.android.ide.eclipse.adt.internal.preferences.AdtPrefs; +import com.android.ide.eclipse.adt.internal.project.BaseProjectHelper; +import com.android.ide.eclipse.adt.internal.sdk.AndroidTargetData; +import com.android.ide.eclipse.adt.internal.sdk.Sdk; +import com.android.ide.eclipse.adt.internal.wizards.newproject.NewProjectCreator; +import com.android.ide.eclipse.adt.internal.wizards.newproject.NewProjectWizardState; +import com.android.ide.eclipse.adt.internal.wizards.newproject.NewProjectWizardState.Mode; +import com.android.ide.eclipse.tests.SdkLoadingTestCase; +import com.android.sdklib.IAndroidTarget; + +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.Path; +import org.eclipse.jdt.core.IJavaProject; +import org.eclipse.jface.operation.IRunnableContext; +import org.eclipse.jface.operation.IRunnableWithProgress; +import org.eclipse.jface.text.source.ISourceViewer; +import org.eclipse.swt.graphics.Point; +import org.eclipse.wst.sse.core.StructuredModelManager; +import org.eclipse.wst.sse.core.internal.provisional.IModelManager; +import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel; +import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument; + +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.InputStream; +import java.lang.reflect.InvocationTargetException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@SuppressWarnings({"restriction", "javadoc"}) +public abstract class AdtProjectTest extends SdkLoadingTestCase { + private static final int TARGET_API_LEVEL = 16; + public static final String TEST_PROJECT_PACKAGE = "com.android.eclipse.tests"; //$NON-NLS-1$ + private static final long TESTS_START_TIME = System.currentTimeMillis(); + private static final String PROJECTNAME_PREFIX = "testproject-"; + + /** + * We don't stash the project used by each test case as a field such that test cases + * can share a single project instance (which is typically much faster). + * However, see {@link #getProjectName()} for exceptions to this sharing scheme. + */ + private static Map<String, IProject> sProjectMap = new HashMap<String, IProject>(); + + @Override + protected String getTestDataRelPath() { + return "eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/" + + "internal/editors/layout/refactoring/testdata"; + } + + @Override + protected InputStream getTestResource(String relativePath, boolean expectExists) { + String path = "testdata" + File.separator + relativePath; //$NON-NLS-1$ + InputStream stream = + AdtProjectTest.class.getResourceAsStream(path); + if (!expectExists && stream == null) { + return null; + } + return stream; + } + + @Override + protected void setUp() throws Exception { + super.setUp(); + + // Prevent preview icon computation during plugin test to make test faster + if (AdtPlugin.getDefault() == null) { + fail("This test must be run as an Eclipse plugin test, not a plain JUnit test!"); + } + AdtPrefs.getPrefs().setPaletteModes("ICON_TEXT"); //$NON-NLS-1$ + + getProject(); + + Sdk current = Sdk.getCurrent(); + assertNotNull(current); + LoadStatus sdkStatus = AdtPlugin.getDefault().getSdkLoadStatus(); + assertSame(LoadStatus.LOADED, sdkStatus); + IAndroidTarget target = current.getTarget(getProject()); + IJavaProject javaProject = BaseProjectHelper.getJavaProject(getProject()); + assertNotNull(javaProject); + int iterations = 0; + while (true) { + if (iterations == 100) { + fail("Couldn't load target; ran out of time"); + } + LoadStatus status = current.checkAndLoadTargetData(target, javaProject); + if (status == LoadStatus.FAILED) { + fail("Couldn't load target " + target); + } + if (status != LoadStatus.LOADING) { + break; + } + Thread.sleep(250); + iterations++; + } + AndroidTargetData targetData = current.getTargetData(target); + assertNotNull(targetData); + LayoutDescriptors layoutDescriptors = targetData.getLayoutDescriptors(); + assertNotNull(layoutDescriptors); + List<ViewElementDescriptor> viewDescriptors = layoutDescriptors.getViewDescriptors(); + assertNotNull(viewDescriptors); + assertTrue(viewDescriptors.size() > 0); + List<ViewElementDescriptor> layoutParamDescriptors = + layoutDescriptors.getLayoutDescriptors(); + assertNotNull(layoutParamDescriptors); + assertTrue(layoutParamDescriptors.size() > 0); + } + + /** Set to true if the subclass test case should use a per-instance project rather + * than a shared project. This is needed by projects which modify the project in such + * a way that it affects what other tests see (for example, the quickfix resource creation + * tests will add in new resources, which the code completion tests will then list as + * possible matches if the code completion test is run after the quickfix test.) + * @return true to create a per-instance project instead of the default shared project + */ + protected boolean testCaseNeedsUniqueProject() { + return false; + } + + protected boolean testNeedsUniqueProject() { + return false; + } + + @Override + protected boolean validateSdk(IAndroidTarget target) { + // Not quite working yet. When enabled will make tests run faster. + //if (target.getVersion().getApiLevel() < TARGET_API_LEVEL) { + // return false; + //} + + return true; + } + + /** Returns a name to use for the project used in this test. Subclasses do not need to + * override this if they can share a project with others - which is the case if they do + * not modify the project in a way that does not affect other tests. For example + * the resource quickfix test will create new resources which affect what shows up + * in the code completion results, so the quickfix tests will override this method + * to produce a unique project for its own tests. + */ + private String getProjectName() { + if (testNeedsUniqueProject()) { + return PROJECTNAME_PREFIX + getClass().getSimpleName() + "-" + getName(); + } else if (testCaseNeedsUniqueProject()) { + return PROJECTNAME_PREFIX + getClass().getSimpleName(); + } else { + return PROJECTNAME_PREFIX + TESTS_START_TIME; + } + } + + protected IProject getProject() { + String projectName = getProjectName(); + IProject project = sProjectMap.get(projectName); + if (project == null) { + project = createProject(projectName); + assertNotNull(project); + sProjectMap.put(projectName, project); + } + if (!testCaseNeedsUniqueProject() && !testNeedsUniqueProject()) { + addCleanupDir(AdtUtils.getAbsolutePath(project).toFile()); + } + addCleanupDir(project.getFullPath().toFile()); + return project; + } + + protected IFile getTestDataFile(IProject project, String name) throws Exception { + return getTestDataFile(project, name, name); + } + + protected IFile getLayoutFile(IProject project, String name) throws Exception { + return getTestDataFile(project, name, FD_RES + "/" + FD_RES_LAYOUT + "/" + name); + } + + protected IFile getValueFile(IProject project, String name) throws Exception { + return getTestDataFile(project, name, FD_RES + "/" + FD_RES_VALUES + "/" + name); + } + + protected IFile getTestDataFile(IProject project, String sourceName, + String destPath) throws Exception { + return getTestDataFile(project, sourceName, destPath, false); + } + + protected IFile getTestDataFile(IProject project, String sourceName, + String destPath, boolean overwrite) throws Exception { + String[] split = destPath.split("/"); //$NON-NLS-1$ + IContainer parent; + String name; + if (split.length == 1) { + parent = project; + name = destPath; + } else { + IFolder folder = project.getFolder(split[0]); + NullProgressMonitor monitor = new NullProgressMonitor(); + if (!folder.exists()) { + folder.create(true /* force */, true /* local */, monitor); + } + for (int i = 1, n = split.length; i < n -1; i++) { + IFolder subFolder = folder.getFolder(split[i]); + if (!subFolder.exists()) { + subFolder.create(true /* force */, true /* local */, monitor); + } + folder = subFolder; + } + name = split[split.length - 1]; + parent = folder; + } + IFile file = parent.getFile(new Path(name)); + if (overwrite && file.exists()) { + String currentContents = AdtPlugin.readFile(file); + String newContents = readTestFile(sourceName, true); + if (currentContents == null || !currentContents.equals(newContents)) { + file.delete(true, new NullProgressMonitor()); + } else { + return file; + } + } + if (!file.exists()) { + String xml = readTestFile(sourceName, true); + InputStream bstream = new ByteArrayInputStream(xml.getBytes("UTF-8")); //$NON-NLS-1$ + NullProgressMonitor monitor = new NullProgressMonitor(); + file.create(bstream, false /* force */, monitor); + } + + return file; + } + + protected IProject createProject(String name) { + IAndroidTarget target = null; + + IAndroidTarget[] targets = getSdk().getTargets(); + for (IAndroidTarget t : targets) { + if (!t.isPlatform()) { + continue; + } + if (t.getVersion().getApiLevel() >= TARGET_API_LEVEL) { + target = t; + break; + } + } + assertNotNull(target); + + IRunnableContext context = new IRunnableContext() { + @Override + public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable) + throws InvocationTargetException, InterruptedException { + runnable.run(new NullProgressMonitor()); + } + }; + NewProjectWizardState state = new NewProjectWizardState(Mode.ANY); + state.projectName = name; + state.target = target; + state.packageName = TEST_PROJECT_PACKAGE; + state.activityName = name; + state.applicationName = name; + state.createActivity = false; + state.useDefaultLocation = true; + if (getMinSdk() != -1) { + state.minSdk = Integer.toString(getMinSdk()); + } + + NewProjectCreator creator = new NewProjectCreator(state, context); + creator.createAndroidProjects(); + return validateProjectExists(name); + } + + protected int getMinSdk() { + return -1; + } + + public void createTestProject() { + IAndroidTarget target = null; + + IAndroidTarget[] targets = getSdk().getTargets(); + for (IAndroidTarget t : targets) { + if (t.getVersion().getApiLevel() >= TARGET_API_LEVEL) { + target = t; + break; + } + } + assertNotNull(target); + } + + protected static IProject validateProjectExists(String name) { + IProject iproject = getProject(name); + assertTrue(String.format("%s project not created", name), iproject.exists()); + assertTrue(String.format("%s project not opened", name), iproject.isOpen()); + return iproject; + } + + private static IProject getProject(String name) { + IProject iproject = ResourcesPlugin.getWorkspace().getRoot().getProject(name); + return iproject; + } + + protected int getCaretOffset(IFile file, String caretLocation) { + assertTrue(caretLocation, caretLocation.contains("^")); + + String fileContent = AdtPlugin.readFile(file); + return getCaretOffset(fileContent, caretLocation); + } + + /** + * If the given caret location string contains a selection range, select that range in + * the given viewer + * + * @param viewer the viewer to contain the selection + * @param caretLocation the location string + */ + protected int updateCaret(ISourceViewer viewer, String caretLocation) { + assertTrue(caretLocation, caretLocation.contains("^")); //$NON-NLS-1$ + + int caretDelta = caretLocation.indexOf("^"); //$NON-NLS-1$ + assertTrue(caretLocation, caretDelta != -1); + String text = viewer.getTextWidget().getText(); + + int length = 0; + + // String around caret/range without the range and caret marker characters + String caretContext; + + if (caretLocation.contains("[^")) { //$NON-NLS-1$ + caretDelta--; + assertTrue(caretLocation, caretLocation.startsWith("[^", caretDelta)); //$NON-NLS-1$ + + int caretRangeEnd = caretLocation.indexOf(']', caretDelta + 2); + assertTrue(caretLocation, caretRangeEnd != -1); + length = caretRangeEnd - caretDelta - 2; + assertTrue(length > 0); + caretContext = caretLocation.substring(0, caretDelta) + + caretLocation.substring(caretDelta + 2, caretRangeEnd) + + caretLocation.substring(caretRangeEnd + 1); + } else { + caretContext = caretLocation.substring(0, caretDelta) + + caretLocation.substring(caretDelta + 1); // +1: skip "^" + } + + int caretContextIndex = text.indexOf(caretContext); + + assertTrue("Caret content " + caretContext + " not found in file", + caretContextIndex != -1); + + int offset = caretContextIndex + caretDelta; + viewer.setSelectedRange(offset, length); + + return offset; + } + + protected String addSelection(String newFileContents, Point selectedRange) { + int selectionBegin = selectedRange.x; + int selectionEnd = selectionBegin + selectedRange.y; + return addSelection(newFileContents, selectionBegin, selectionEnd); + } + + @Override + protected String removeSessionData(String data) { + data = super.removeSessionData(data); + if (getProject() != null) { + data = data.replace(getProject().getName(), "PROJECTNAME"); + } + + return data; + } + + public static ViewElementDescriptor createDesc(String name, String fqn, boolean hasChildren) { + if (hasChildren) { + return new ViewElementDescriptor(name, name, fqn, "", "", new AttributeDescriptor[0], + new AttributeDescriptor[0], new ElementDescriptor[1], false); + } else { + return new ViewElementDescriptor(name, fqn); + } + } + + public static UiViewElementNode createNode(UiViewElementNode parent, String fqn, + boolean hasChildren) { + String name = fqn.substring(fqn.lastIndexOf('.') + 1); + ViewElementDescriptor descriptor = createDesc(name, fqn, hasChildren); + if (parent == null) { + // All node hierarchies should be wrapped inside a document node at the root + parent = new UiViewElementNode(createDesc("doc", "doc", true)); + } + return (UiViewElementNode) parent.appendNewUiChild(descriptor); + } + + public static UiViewElementNode createNode(String fqn, boolean hasChildren) { + return createNode(null, fqn, hasChildren); + } + + /** Special editor context set on the model to be rendered */ + protected static class TestLayoutEditorDelegate extends LayoutEditorDelegate { + + public TestLayoutEditorDelegate( + IFile file, + IStructuredDocument structuredDocument, + UiDocumentNode uiRootNode) { + super(new TestAndroidXmlCommonEditor(file, structuredDocument, uiRootNode)); + } + + static class TestAndroidXmlCommonEditor extends CommonXmlEditor { + + private final IFile mFile; + private final IStructuredDocument mStructuredDocument; + private UiDocumentNode mUiRootNode; + + TestAndroidXmlCommonEditor( + IFile file, + IStructuredDocument structuredDocument, + UiDocumentNode uiRootNode) { + mFile = file; + mStructuredDocument = structuredDocument; + mUiRootNode = uiRootNode; + } + + @Override + public IFile getInputFile() { + return mFile; + } + + @Override + public IProject getProject() { + return mFile.getProject(); + } + + @Override + public IStructuredDocument getStructuredDocument() { + return mStructuredDocument; + } + + @Override + public UiDocumentNode getUiRootNode() { + return mUiRootNode; + } + + @Override + public void editorDirtyStateChanged() { + } + + @Override + public IStructuredModel getModelForRead() { + IModelManager mm = StructuredModelManager.getModelManager(); + if (mm != null) { + try { + return mm.getModelForRead(mFile); + } catch (Exception e) { + fail(e.toString()); + } + } + + return null; + } + } + } + + public void testDummy() { + // This class contains shared test functionality for testcase subclasses, + // but without an actual test in the class JUnit complains (even if we make + // it abstract) + } +} diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/ChangeLayoutRefactoringTest.java b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/ChangeLayoutRefactoringTest.java new file mode 100644 index 000000000..a716a75a3 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/ChangeLayoutRefactoringTest.java @@ -0,0 +1,136 @@ +/* + * 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.refactoring; + +import static com.android.SdkConstants.FQCN_GRID_LAYOUT; +import static com.android.SdkConstants.FQCN_LINEAR_LAYOUT; +import static com.android.SdkConstants.FQCN_RELATIVE_LAYOUT; + +import com.android.ide.eclipse.adt.internal.editors.layout.gle2.CanvasViewInfo; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.ltk.core.refactoring.Change; +import org.w3c.dom.Element; + +import java.util.Collections; +import java.util.List; + +@SuppressWarnings("javadoc") +public class ChangeLayoutRefactoringTest extends RefactoringTest { + + public void testChangeLayout1a() throws Exception { + // Test a basic layout which performs some nesting -- tests basic grid layout conversion + checkRefactoring("sample1a.xml", true); + } + + public void testChangeLayout1b() throws Exception { + // Same as 1a, but with different formatting to look for edit handling to for example + // remove a line that is made empty when its only attribute is removed + checkRefactoring("sample1b.xml", true); + } + + public void testChangeLayout2() throws Exception { + // Test code which analyzes an embedded RelativeLayout + checkRefactoring("sample2.xml", true); + } + + public void testChangeLayout3() throws Exception { + // Test handling of LinearLayout "weight" attributes on its children: the child with + // weight > 0 should fill and subsequent children attach on the bottom/right + checkRefactoring("sample3.xml", true); + } + + public void testChangeLayout4() throws Exception { + checkRefactoring("sample4.xml", true); + } + + public void testChangeLayout5() throws Exception { + // Test handling of LinearLayout "gravity" attributes on its children + checkRefactoring("sample5.xml", true); + } + + public void testChangeLayout6() throws Exception { + // Check handling of the LinearLayout "baseline" attribute + checkRefactoring("sample6.xml", true); + } + + public void testGridLayout1() throws Exception { + checkRefactoring(FQCN_GRID_LAYOUT, "sample1a.xml", true); + } + + public void testGridLayout2() throws Exception { + // Test code which analyzes an embedded RelativeLayout + checkRefactoring(FQCN_GRID_LAYOUT, "sample2.xml", true); + } + + public void testGridLayout5() throws Exception { + // Test handling of LinearLayout "gravity" attributes on its children + checkRefactoring(FQCN_GRID_LAYOUT, "sample5.xml", true); + } + + public void testConvertToGrid() throws Exception { + checkRefactoring(FQCN_GRID_LAYOUT, "sample9.xml", true); + } + + public void testConvertFromGrid() throws Exception { + checkRefactoring(FQCN_LINEAR_LAYOUT, "sample10.xml", true); + } + + private void checkRefactoring(String basename, boolean flatten) throws Exception { + checkRefactoring(FQCN_RELATIVE_LAYOUT, basename, flatten); + } + + public void testInitialAttributes() throws Exception { + checkRefactoring(FQCN_LINEAR_LAYOUT, "sample10.xml", true, "android:orientation=vertical"); + } + + public void testInsertSpacer() throws Exception { + checkRefactoring(FQCN_GRID_LAYOUT, "sample11.xml", true); + } + + private void checkRefactoring(String newLayoutType, String basename, + boolean flatten) throws Exception { + checkRefactoring(newLayoutType, basename, flatten, null); + } + + @Override + protected int getMinSdk() { + return 14; + } + + private void checkRefactoring(String newLayoutType, String basename, + boolean flatten, String initialAttributes) throws Exception { + IFile file = getLayoutFile(getProject(), basename); + TestContext info = setupTestContext(file, basename); + TestLayoutEditorDelegate layoutEditor = info.mLayoutEditorDelegate; + CanvasViewInfo rootView = info.mRootView; + Element element = info.mElement; + + List<Element> selectedElements = Collections.singletonList(element); + ChangeLayoutRefactoring refactoring = new ChangeLayoutRefactoring(selectedElements, + layoutEditor); + refactoring.setFlatten(flatten); + refactoring.setType(newLayoutType); + if (initialAttributes != null) { + refactoring.setInitializedAttributes(initialAttributes); + } + refactoring.setRootView(rootView); + + List<Change> changes = refactoring.computeChanges(new NullProgressMonitor()); + checkEdits(basename, changes); + } +} diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/ChangeViewRefactoringTest.java b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/ChangeViewRefactoringTest.java new file mode 100644 index 000000000..582ed0f27 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/ChangeViewRefactoringTest.java @@ -0,0 +1,59 @@ +/* + * 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.refactoring; + +import static com.android.SdkConstants.FQCN_RADIO_BUTTON; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.ltk.core.refactoring.Change; +import org.w3c.dom.Element; + +import java.util.List; + +public class ChangeViewRefactoringTest extends RefactoringTest { + + public void testChangeView1() throws Exception { + checkRefactoring("sample1a.xml", FQCN_RADIO_BUTTON, "@+id/button1", "@+id/button6"); + } + + public void testChangeView2() throws Exception { + // Tests (1) updating references to the renamed id of the changed widgets + // (e.g. button3 is renamed to imageButton1 and layout references to button3 + // must be updated), and (2) removal of attributes not available in the new type + // (the text property is removed since it is not available on the new widget + // type ImageButton) + checkRefactoring("sample2.xml", "android.widget.ImageButton", + "@+id/button3", "@+id/button5"); + } + + private void checkRefactoring(String basename, String newType, + String... ids) throws Exception { + assertTrue(ids.length > 0); + + IFile file = getLayoutFile(getProject(), basename); + TestContext info = setupTestContext(file, basename); + TestLayoutEditorDelegate layoutEditor = info.mLayoutEditorDelegate; + List<Element> selectedElements = getElements(info.mElement, ids); + + ChangeViewRefactoring refactoring = new ChangeViewRefactoring(selectedElements, + layoutEditor); + refactoring.setType(newType); + + List<Change> changes = refactoring.computeChanges(new NullProgressMonitor()); + checkEdits(basename, changes); + } +} diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/ExtractIncludeRefactoringTest.java b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/ExtractIncludeRefactoringTest.java new file mode 100644 index 000000000..1667649c5 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/ExtractIncludeRefactoringTest.java @@ -0,0 +1,170 @@ +/* + * 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.refactoring; + +import static com.android.SdkConstants.DOT_XML; + +import com.android.ide.eclipse.adt.AdtPlugin; +import com.android.ide.eclipse.adt.internal.preferences.AdtPrefs; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.ltk.core.refactoring.Change; +import org.eclipse.ltk.core.refactoring.TextFileChange; +import org.w3c.dom.Element; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class ExtractIncludeRefactoringTest extends RefactoringTest { + + @Override + protected boolean autoFormat() { + return false; + } + + @Override + protected boolean testCaseNeedsUniqueProject() { + // Because some of these tests look at ALL layouts in the project + // to identify matches + return true; + } + + public void testExtract1() throws Exception { + // Basic: Extract a single button + checkRefactoring("sample3.xml", "newlayout1", false, null, 2, false /* diffs */, + "@+id/button2"); + } + + public void testExtract2() throws Exception { + // Extract a couple of elements + checkRefactoring("sample3.xml", "newlayout2", false, null, 2, false /* diffs */, + "@+id/button2", "@+id/android_logo"); + } + + public void testExtract3() throws Exception { + // Test to make sure layout attributes are updated + checkRefactoring("sample2.xml", "newlayout3", false, null, 2, false /* diffs */, + "@+id/button3"); + } + + public void testExtract4() throws Exception { + // Tests extracting from -multiple- files (as well as with custom android namespace + // prefix) + + // Make sure the variation-files exist + Map<IPath, String> extraFiles = new HashMap<IPath, String>(); + extraFiles.put(getTestDataFile(getProject(), "sample3-variation1.xml", + "res/layout-land/sample3.xml").getProjectRelativePath(), + "sample3-variation1.xml"); + extraFiles.put(getTestDataFile(getProject(), "sample3-variation2.xml", + "res/layout-xlarge-land/sample3.xml").getProjectRelativePath(), + "sample3-variation2.xml"); + + checkRefactoring("sample3.xml", "newlayout3", true, extraFiles, 4, false /* diffs */, + "@+id/android_logo"); + } + + public void testExtract5() throws Exception { + // Tests extracting from multiple files with -contiguous regions-. + + // Make sure the variation-files exist + Map<IPath, String> extraFiles = new HashMap<IPath, String>(); + extraFiles.put(getTestDataFile(getProject(), "sample3-variation1.xml", + "res/layout-land/sample3.xml").getProjectRelativePath(), + "sample3-variation1.xml"); + extraFiles.put(getTestDataFile(getProject(), "sample3-variation2.xml", + "res/layout-xlarge-land/sample3.xml").getProjectRelativePath(), + "sample3-variation2.xml"); + + checkRefactoring("sample3.xml", "newlayout3", true, extraFiles, 4, false /* diffs */, + "@+id/android_logo", "@+id/button1"); + } + + public void testExtract6() throws Exception { + // Tests extracting from multiple files where the layouts are completely + // different/unrelated files + + // Create the duplicate files + Map<IPath, String> extraFiles = new HashMap<IPath, String>(); + extraFiles.put(getTestDataFile(getProject(), "sample1a.xml", + "res/layout/sample1a.xml").getProjectRelativePath(), + "sample1a.xml"); + extraFiles.put(getTestDataFile(getProject(), "sample7.xml", "res/layout/sample7.xml") + .getProjectRelativePath(), "sample7.xml"); + extraFiles.put(getTestDataFile(getProject(), "sample8.xml", "res/layout/sample8.xml") + .getProjectRelativePath(), "sample8.xml"); + + checkRefactoring("sample7.xml", "newlayout6", true, extraFiles, 4, true /* diffs */, + "@+id/linearLayout4"); + } + + public void testExtract7() throws Exception { + // Just like testExtract6, except we turn on auto-formatting + IPreferenceStore store = AdtPlugin.getDefault().getPreferenceStore(); + AdtPrefs.init(store); + AdtPrefs prefs = AdtPrefs.getPrefs(); + prefs.initializeStoreWithDefaults(store); + store.setValue(AdtPrefs.PREFS_FORMAT_GUI_XML, true); + prefs.loadValues(null); + + assertTrue(AdtPrefs.getPrefs().getFormatGuiXml()); + + testExtract6(); + } + + + private void checkRefactoring(String basename, String layoutName, + boolean replaceOccurrences, Map<IPath,String> extraFiles, + int expectedModifiedFileCount, boolean createDiffs, String... ids) throws Exception { + assertTrue(ids.length > 0); + + IFile file = getLayoutFile(getProject(), basename); + TestContext info = setupTestContext(file, basename); + TestLayoutEditorDelegate layoutEditor = info.mLayoutEditorDelegate; + List<Element> selectedElements = getElements(info.mElement, ids); + + ExtractIncludeRefactoring refactoring = new ExtractIncludeRefactoring(selectedElements, + layoutEditor); + refactoring.setLayoutName(layoutName); + refactoring.setReplaceOccurrences(replaceOccurrences); + List<Change> changes = refactoring.computeChanges(new NullProgressMonitor()); + + assertTrue(changes.size() >= 3); + + Map<IPath,String> fileToGolden = new HashMap<IPath,String>(); + IPath sourcePath = file.getProjectRelativePath(); + fileToGolden.put(sourcePath, basename); + IPath newPath = sourcePath.removeLastSegments(1).append(layoutName + DOT_XML); + fileToGolden.put(newPath, layoutName + DOT_XML); + if (extraFiles != null) { + fileToGolden.putAll(extraFiles); + } + + checkEdits(changes, fileToGolden, createDiffs); + + int modifiedFileCount = 0; + for (Change change : changes) { + if (change instanceof TextFileChange) { + modifiedFileCount++; + } + } + assertEquals(expectedModifiedFileCount, modifiedFileCount); + } +} diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/ExtractStyleRefactoringTest.java b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/ExtractStyleRefactoringTest.java new file mode 100644 index 000000000..f64555dd6 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/ExtractStyleRefactoringTest.java @@ -0,0 +1,232 @@ +/* + * 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.refactoring; + +import com.android.utils.Pair; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.jface.text.ITextSelection; +import org.eclipse.jface.text.TextSelection; +import org.eclipse.ltk.core.refactoring.Change; +import org.eclipse.ltk.core.refactoring.TextFileChange; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.ide.IDE; +import org.w3c.dom.Attr; +import org.w3c.dom.Element; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + +public class ExtractStyleRefactoringTest extends RefactoringTest { + @Override + protected boolean testCaseNeedsUniqueProject() { + return true; + } + + public void testExtract1() throws Exception { + // Test extracting into a new style file + checkRefactoring("extractstyle1.xml", "newstyles.xml", "newstyle", + false /* removeExtracted */, false /* applyStyle */, null, 1, "@+id/button2"); + } + + public void testExtract1b() throws Exception { + // Extract and apply new style + checkRefactoring("extractstyle1.xml", "newstyles2.xml", "newstyle", + false /* removeExtracted */, true /* applyStyle */, null, 2, "@+id/button2"); + } + + public void testExtract1c() throws Exception { + // Extract and remove extracted + checkRefactoring("extractstyle1.xml", "newstyles3.xml", "newstyle", + true /* removeExtracted */, false /* applyStyle */, null, 2, "@+id/button2"); + } + + public void testExtract1d() throws Exception { + // Extract and apply style and remove extracted + checkRefactoring("extractstyle1.xml", "newstyles4.xml", "newstyle", + true /* removeExtracted */, true /* applyStyle */, null, 2, "@+id/button2"); + } + + public void testExtract2() throws Exception { + getTestDataFile(getProject(), "navigationstyles.xml", "res/values/navigationstyles.xml"); + + // -Modify- the existing styles.xml file + checkRefactoring("extractstyle1.xml", "navigationstyles.xml", "newstyle", + true /* removeExtracted */, true /* applyStyle */, null, 2, "@+id/button2"); + } + + public void testExtract3() throws Exception { + // Select multiple elements - overlap in values. + checkRefactoring("extractstyle1.xml", "newstyles4.xml", "newstyle", + true /* removeExtracted */, true /* applyStyle */, null, 2, + "@+id/button1", "@+id/button2"); + } + + // This test fails for some reason - not in the refactoring (checked manually) + // but the DOM model returns null when run in a test context. + public void testExtract4() throws Exception { + // Test extracting on a single caret position over an attribute: Should extract + // just that one attribute + checkRefactoringByOffset("extractstyle1.xml", "newstyles5.xml", "newstyle", + true /* removeExtracted */, true /* applyStyle */, null, 2, + "android:text^Color=\"#FF00FF\"", "android:text^Color=\"#FF00FF\""); + } + + public void testExtract5() throws Exception { + // Test extracting on a range selection inside an element: should extract just + // the attributes that overlap the selection + checkRefactoringByOffset("extractstyle1.xml", "newstyles6.xml", "newstyle", + true /* removeExtracted */, true /* applyStyle */, null, 2, + "android:^textSize=\"20pt", + "android:id=\"@+id/button1\" android:layout_a^lignParentBottom"); + } + + public void testExtract6() throws Exception { + // Test extracting on a single caret position which is not over any attributes: + checkRefactoringByOffset("extractstyle1.xml", "newstyles7.xml", "newstyle", + true /* removeExtracted */, true /* applyStyle */, null, 0, + "<Bu^tton", "<Bu^tton"); + } + + public void testExtract7() throws Exception { + // Verify that even with a different namespace prefix we end up with android: + // in the extracted style + checkRefactoring("extractstyle2.xml", "newstyles8.xml", "newstyle", + true /* removeExtracted */, true /* applyStyle */, null, 2, + "@+id/button1", "@+id/button2"); + } + + public void testExtract8() throws Exception { + // Test setting parent style + checkRefactoring("extractstyle1.xml", "newstyles3.xml", "newstyle", + true /* removeExtracted */, false /* applyStyle */, "android:Widget.Button", + 2, "@+id/button2"); + } + + // Check extract style on a selection of elements + private void checkRefactoring(String basename, String styleFileName, String newStyleName, + boolean removeExtracted, boolean applyStyle, String parentStyle, + int expectedModifiedFileCount, String... ids) throws Exception { + assertTrue(ids.length > 0); + + IFile file = getLayoutFile(getProject(), basename); + TestContext info = setupTestContext(file, basename); + TestLayoutEditorDelegate layoutEditor = info.mLayoutEditorDelegate; + List<Element> selectedElements = getElements(info.mElement, ids); + + // Open the file such that ModelManager.getExistingModelForRead() in DomUtilities + // will succeed + IWorkbench workbench = PlatformUI.getWorkbench(); + IWorkbenchWindow activeWorkbenchWindow = workbench.getActiveWorkbenchWindow(); + IWorkbenchPage page = activeWorkbenchWindow.getActivePage(); + IDE.openEditor(page, file); + + ExtractStyleRefactoring refactoring = new ExtractStyleRefactoring(selectedElements, + layoutEditor); + checkRefactoring(basename, styleFileName, newStyleName, removeExtracted, applyStyle, + parentStyle, expectedModifiedFileCount, file, refactoring); + } + + // Check extract style against a set of editor text locations + private void checkRefactoringByOffset(String basename, String styleFileName, + String newStyleName, boolean removeExtracted, boolean applyStyle, + String parentStyle, + int expectedModifiedFileCount, String beginCaretLocation, String endCaretLocation) + throws Exception { + IFile file = getLayoutFile(getProject(), basename); + int beginOffset = getCaretOffset(file, beginCaretLocation); + int endOffset = getCaretOffset(file, endCaretLocation); + + TestContext info = setupTestContext(file, basename); + TestLayoutEditorDelegate layoutEditor = info.mLayoutEditorDelegate; + + // Open the file such that ModelManager.getExistingModelForRead() in DomUtilities + // will succeed + IWorkbench workbench = PlatformUI.getWorkbench(); + IWorkbenchWindow activeWorkbenchWindow = workbench.getActiveWorkbenchWindow(); + IWorkbenchPage page = activeWorkbenchWindow.getActivePage(); + IDE.openEditor(page, file); + + ITextSelection selection = new TextSelection(beginOffset, endOffset - beginOffset); + ExtractStyleRefactoring refactoring = new ExtractStyleRefactoring(file, + layoutEditor, selection, null); + checkRefactoring(basename, styleFileName, newStyleName, removeExtracted, applyStyle, + parentStyle, expectedModifiedFileCount, file, refactoring); + } + + // Common test code used by the other two check methods + private void checkRefactoring(String basename, String styleFileName, String newStyleName, + boolean removeExtracted, boolean applyStyle, String parentStyle, + int expectedModifiedFileCount, IFile file, + ExtractStyleRefactoring refactoring) throws Exception { + refactoring.setStyleName(newStyleName); + refactoring.setApplyStyle(applyStyle); + refactoring.setRemoveExtracted(removeExtracted); + refactoring.setStyleFileName(styleFileName); + refactoring.setParent(parentStyle); + + // Pick the attributes to extract -- for now everything (and where there are + // conflicting values, pick the first one) + Pair<Map<String, List<Attr>>, Set<Attr>> result = refactoring.getAvailableAttributes(); + Map<String, List<Attr>> availableAttributes = result.getFirst(); + Set<Attr> selected = result.getSecond(); + List<Attr> chosenAttributes = new ArrayList<Attr>(); + for (List<Attr> list : availableAttributes.values()) { + Collections.sort(list, new Comparator<Attr>() { + @Override + public int compare(Attr a1, Attr a2) { + return a1.getValue().compareTo(a2.getValue()); + } + }); + Attr attr = list.get(0); + if (selected.contains(attr)) { + chosenAttributes.add(attr); + } + } + refactoring.setChosenAttributes(chosenAttributes); + + List<Change> changes = refactoring.computeChanges(new NullProgressMonitor()); + assertEquals(expectedModifiedFileCount, changes.size()); + + Map<IPath,String> fileToGolden = new HashMap<IPath,String>(); + IPath sourcePath = file.getProjectRelativePath(); + fileToGolden.put(sourcePath, basename); + IPath newPath = refactoring.getStyleFile(getProject()).getProjectRelativePath(); + fileToGolden.put(newPath, styleFileName); + + checkEdits(changes, fileToGolden, true); + + int modifiedFileCount = 0; + for (Change change : changes) { + if (change instanceof TextFileChange) { + modifiedFileCount++; + } + } + assertEquals(expectedModifiedFileCount, modifiedFileCount); + } + +} diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/RefactoringAssistantTest.java b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/RefactoringAssistantTest.java new file mode 100644 index 000000000..b22717991 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/RefactoringAssistantTest.java @@ -0,0 +1,128 @@ +/* + * 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.refactoring; + +import static com.android.SdkConstants.FD_RES; +import static com.android.SdkConstants.FD_RES_LAYOUT; + +import com.android.ide.eclipse.adt.AdtPlugin; +import com.android.ide.eclipse.adt.internal.editors.AndroidXmlEditor; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; +import org.eclipse.jface.text.contentassist.ICompletionProposal; +import org.eclipse.jface.text.quickassist.IQuickAssistInvocationContext; +import org.eclipse.jface.text.source.ISourceViewer; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.ide.IDE; + +public class RefactoringAssistantTest extends AdtProjectTest { + public void testAssistant1() throws Exception { + // "Extract String" + checkFixes("sample1a.xml", "<Button android:text=\"Fir^stButton\""); + } + + public void testAssistant2() throws Exception { + // Visual refactoring operations + checkFixes("sample1a.xml", "<Bu^tton android:text"); + } + + public void testAssistant3() throws Exception { + checkFixes("sample1a.xml", "<Button andr^oid:text=\"FirstButton\""); + } + + public void testAssistant4() throws Exception { + // Check for resource rename refactoring (and don't offer extract string) + checkFixes("sample1a.xml", "android:id=\"@+id/Linea^rLayout2\""); + } + + private void checkFixes(String name, String caretLocation) + throws Exception { + IProject project = getProject(); + IFile file = getTestDataFile(project, name, FD_RES + "/" + FD_RES_LAYOUT + "/" + name); + + // Determine the offset + String fileContent = AdtPlugin.readFile(file); + int caretDelta = caretLocation.indexOf("^"); + assertTrue(caretLocation, caretDelta != -1); + String caretContext = caretLocation.substring(0, caretDelta) + + caretLocation.substring(caretDelta + "^".length()); + int caretContextIndex = fileContent.indexOf(caretContext); + assertTrue("Caret content " + caretContext + " not found in file", + caretContextIndex != -1); + final int offset = caretContextIndex + caretDelta; + + + RefactoringAssistant refactoringAssistant = new RefactoringAssistant(); + + // Open file + IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); + assertNotNull(page); + IEditorPart editor = IDE.openEditor(page, file); + assertTrue(editor instanceof AndroidXmlEditor); + AndroidXmlEditor layoutEditor = (AndroidXmlEditor) editor; + final ISourceViewer viewer = layoutEditor.getStructuredSourceViewer(); + + IQuickAssistInvocationContext invocationContext = new IQuickAssistInvocationContext() { + @Override + public int getLength() { + return 0; + } + + @Override + public int getOffset() { + return offset; + } + + @Override + public ISourceViewer getSourceViewer() { + return viewer; + } + }; + ICompletionProposal[] proposals = refactoringAssistant + .computeQuickAssistProposals(invocationContext); + + if (proposals != null) { + for (ICompletionProposal proposal : proposals) { + assertNotNull(proposal.getAdditionalProposalInfo()); + assertNotNull(proposal.getImage()); + } + } + + StringBuilder sb = new StringBuilder(1000); + sb.append("Quick assistant in " + name + " for " + caretLocation + ":\n"); + if (proposals != null) { + for (ICompletionProposal proposal : proposals) { + sb.append(proposal.getDisplayString()); + String help = proposal.getAdditionalProposalInfo(); + if (help != null && help.trim().length() > 0) { + sb.append(" : "); + sb.append(help.replace('\n', ' ')); + } + sb.append('\n'); + } + } else { + sb.append("None found.\n"); + } + assertEqualsGolden(name, sb.toString(), "txt"); + + // No "apply" test on these assists since they are interactive. Refactoring + // is tested elsewhere. + } +} diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/RefactoringTest.java b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/RefactoringTest.java new file mode 100644 index 000000000..9565183bc --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/RefactoringTest.java @@ -0,0 +1,334 @@ +/* + * 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.refactoring; + +import static com.android.SdkConstants.ANDROID_WIDGET_PREFIX; +import static com.android.SdkConstants.DOT_XML; + +import com.android.ide.common.rendering.api.ViewInfo; +import com.android.ide.eclipse.adt.AdtPlugin; +import com.android.ide.eclipse.adt.internal.editors.layout.gle2.CanvasViewInfo; +import com.android.ide.eclipse.adt.internal.editors.layout.gle2.DomUtilities; +import com.android.ide.eclipse.adt.internal.editors.layout.uimodel.UiViewElementNode; +import com.android.ide.eclipse.adt.internal.editors.uimodel.UiElementNode; +import com.android.ide.eclipse.adt.internal.preferences.AdtPrefs; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.runtime.IPath; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.text.BadLocationException; +import org.eclipse.jface.text.Document; +import org.eclipse.jface.text.IDocument; +import org.eclipse.ltk.core.refactoring.Change; +import org.eclipse.ltk.core.refactoring.TextFileChange; +import org.eclipse.text.edits.MultiTextEdit; +import org.eclipse.text.edits.TextEdit; +import org.eclipse.wst.sse.core.StructuredModelManager; +import org.eclipse.wst.sse.core.internal.provisional.IModelManager; +import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel; +import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion; +import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument; +import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel; +import org.w3c.dom.Element; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +@SuppressWarnings("restriction") +public class RefactoringTest extends AdtProjectTest { + + protected boolean autoFormat() { + return true; + } + + @Override + protected void setUp() throws Exception { + + // Ensure that the defaults are initialized so for example formatting options are + // initialized properly + IPreferenceStore store = AdtPlugin.getDefault().getPreferenceStore(); + AdtPrefs.init(store); + AdtPrefs prefs = AdtPrefs.getPrefs(); + prefs.initializeStoreWithDefaults(store); + + store.setValue(AdtPrefs.PREFS_FORMAT_GUI_XML, autoFormat()); + + prefs.loadValues(null); + + super.setUp(); + } + + protected static Element findElementById(Element root, String id) { + if (id.equals(VisualRefactoring.getId(root))) { + return root; + } + + for (Element child : DomUtilities.getChildren(root)) { + Element result = findElementById(child, id); + if (result != null) { + return result; + } + } + + return null; + } + + protected static List<Element> getElements(Element root, String... ids) { + List<Element> selectedElements = new ArrayList<Element>(); + for (String id : ids) { + Element element = findElementById(root, id); + assertNotNull(element); + selectedElements.add(element); + } + return selectedElements; + } + + protected void checkEdits(String basename, List<Change> changes) throws BadLocationException, + IOException { + IDocument document = new Document(); + + String xml = readTestFile(basename, false); + if (xml == null) { // New file + xml = ""; //$NON-NLS-1$ + } + document.set(xml); + + for (Change change : changes) { + if (change instanceof TextFileChange) { + TextFileChange tf = (TextFileChange) change; + TextEdit edit = tf.getEdit(); + IFile file = tf.getFile(); + String contents = AdtPlugin.readFile(file); + assertEquals(contents, xml); + if (edit instanceof MultiTextEdit) { + MultiTextEdit edits = (MultiTextEdit) edit; + edits.apply(document); + } else { + edit.apply(document); + } + } else { + System.out.println("Ignoring non-textfilechange in refactoring result"); + } + } + + String actual = document.get(); + + // Ensure that the document is still valid to make sure the edits don't + // mangle it: + org.w3c.dom.Document doc = DomUtilities.parseDocument(actual, true); + assertNotNull(actual, doc); + + assertEqualsGolden(basename, actual); + } + + protected void checkEdits(List<Change> changes, + Map<IPath, String> fileToGoldenName) throws BadLocationException, IOException { + checkEdits(changes, fileToGoldenName, false); + } + + protected void checkEdits(List<Change> changes, + Map<IPath, String> fileToGoldenName, boolean createDiffs) + throws BadLocationException, IOException { + for (Change change : changes) { + if (change instanceof TextFileChange) { + TextFileChange tf = (TextFileChange) change; + IFile file = tf.getFile(); + assertNotNull(file); + IPath path = file.getProjectRelativePath(); + String goldenName = fileToGoldenName.get(path); + assertNotNull("Not found: " + path.toString(), goldenName); + + String xml = readTestFile(goldenName, false); + if (xml == null) { // New file + xml = ""; //$NON-NLS-1$ + } + IDocument document = new Document(); + document.set(xml); + + String before = document.get(); + + TextEdit edit = tf.getEdit(); + if (edit instanceof MultiTextEdit) { + MultiTextEdit edits = (MultiTextEdit) edit; + edits.apply(document); + } else { + edit.apply(document); + } + + String actual = document.get(); + + if (createDiffs) { + // Use a diff as the golden file instead of the after + actual = getDiff(before, actual); + if (goldenName.endsWith(DOT_XML)) { + goldenName = goldenName.substring(0, + goldenName.length() - DOT_XML.length()) + + ".diff"; + } + } + + assertEqualsGolden(goldenName, actual); + } else { + System.out.println("Ignoring non-textfilechange in refactoring result"); + assertNull(change.getAffectedObjects()); + } + } + } + + protected UiViewElementNode createModel(UiViewElementNode parent, Element element) { + List<Element> children = DomUtilities.getChildren(element); + String fqcn = ANDROID_WIDGET_PREFIX + element.getTagName(); + boolean hasChildren = children.size() > 0; + UiViewElementNode node = createNode(parent, fqcn, hasChildren); + node.setXmlNode(element); + for (Element child : children) { + createModel(node, child); + } + + return node; + } + + /** + * Builds up a ViewInfo hierarchy for the given model. This is done by + * reading .info dump files which record the exact pixel sizes of each + * ViewInfo object. These files are assumed to match up exactly with the + * model objects. This is done rather than rendering an actual layout + * hierarchy to insulate the test from pixel difference (in say font size) + * among platforms, as well as tying the test to particulars about relative + * sizes of things which may change with theme adjustments etc. + * <p> + * Each file can be generated by the dump method in the ViewHierarchy. + */ + protected ViewInfo createInfos(UiElementNode model, String relativePath) throws IOException { + String basename = relativePath.substring(0, relativePath.lastIndexOf('.') + 1); + String relative = basename + "info"; //$NON-NLS-1$ + String info = readTestFile(relative, true); + // Parse the info file and build up a model from it + // Each line contains a new info. + // If indented it is a child of the parent. + String[] lines = info.split("\n"); //$NON-NLS-1$ + + // Iteration order for the info file should match exactly the UI model so + // we can just advance the line index sequentially as we traverse + + return create(model, Arrays.asList(lines).iterator()); + } + + protected ViewInfo create(UiElementNode node, Iterator<String> lineIterator) { + // android.widget.LinearLayout [0,36,240,320] + Pattern pattern = Pattern.compile("(\\s*)(\\S+) \\[(\\d+),(\\d+),(\\d+),(\\d+)\\].*"); + assertTrue(lineIterator.hasNext()); + String description = lineIterator.next(); + Matcher matcher = pattern.matcher(description); + assertTrue(matcher.matches()); + //String indent = matcher.group(1); + //String fqcn = matcher.group(2); + String left = matcher.group(3); + String top = matcher.group(4); + String right = matcher.group(5); + String bottom = matcher.group(6); + + ViewInfo view = new ViewInfo(node.getXmlNode().getLocalName(), node, + Integer.parseInt(left), Integer.parseInt(top), + Integer.parseInt(right), Integer.parseInt(bottom)); + + List<UiElementNode> childNodes = node.getUiChildren(); + if (childNodes.size() > 0) { + List<ViewInfo> children = new ArrayList<ViewInfo>(); + for (UiElementNode child : childNodes) { + children.add(create(child, lineIterator)); + } + view.setChildren(children); + } + + return view; + } + + protected TestContext setupTestContext(IFile file, String relativePath) throws Exception { + IStructuredModel structuredModel = null; + org.w3c.dom.Document domDocument = null; + IStructuredDocument structuredDocument = null; + Element element = null; + + try { + IModelManager modelManager = StructuredModelManager.getModelManager(); + structuredModel = modelManager.getModelForRead(file); + if (structuredModel instanceof IDOMModel) { + IDOMModel domModel = (IDOMModel) structuredModel; + domDocument = domModel.getDocument(); + element = domDocument.getDocumentElement(); + structuredDocument = structuredModel.getStructuredDocument(); + } + } finally { + if (structuredModel != null) { + structuredModel.releaseFromRead(); + } + } + + assertNotNull(structuredModel); + assertNotNull(domDocument); + assertNotNull(element); + assertNotNull(structuredDocument); + assertTrue(element instanceof IndexedRegion); + + UiViewElementNode model = createModel(null, element); + ViewInfo info = createInfos(model, relativePath); + CanvasViewInfo rootView = CanvasViewInfo.create(info, true /* layoutlib5 */).getFirst(); + TestLayoutEditorDelegate layoutEditor = + new TestLayoutEditorDelegate(file, structuredDocument, null); + + TestContext testInfo = createTestContext(); + testInfo.mFile = file; + testInfo.mStructuredModel = structuredModel; + testInfo.mStructuredDocument = structuredDocument; + testInfo.mElement = element; + testInfo.mDomDocument = domDocument; + testInfo.mUiModel = model; + testInfo.mViewInfo = info; + testInfo.mRootView = rootView; + testInfo.mLayoutEditorDelegate = layoutEditor; + + return testInfo; + } + + protected TestContext createTestContext() { + return new TestContext(); + } + + protected static class TestContext { + protected IFile mFile; + protected IStructuredModel mStructuredModel; + protected IStructuredDocument mStructuredDocument; + protected org.w3c.dom.Document mDomDocument; + protected Element mElement; + protected UiViewElementNode mUiModel; + protected ViewInfo mViewInfo; + protected CanvasViewInfo mRootView; + protected TestLayoutEditorDelegate mLayoutEditorDelegate; + } + + @Override + public void testDummy() { + // To avoid JUnit warning that this class contains no tests, even though + // this is an abstract class and JUnit shouldn't try + } +} diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/UnwrapRefactoringTest.java b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/UnwrapRefactoringTest.java new file mode 100644 index 000000000..e03ea9e06 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/UnwrapRefactoringTest.java @@ -0,0 +1,58 @@ +/* + * 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.refactoring; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.ltk.core.refactoring.Change; +import org.eclipse.ltk.core.refactoring.RefactoringStatus; +import org.w3c.dom.Element; + +import java.util.List; + +public class UnwrapRefactoringTest extends RefactoringTest { + + public void testUnwrap1() throws Exception { + // Unwrap view with parent, no children - this will unwrap the parent (frame layout) + checkRefactoring("unwrap.xml", "@+id/button"); + } + + public void testUnwrap2() throws Exception { + // Unwrap view with parent and children; this should unwrap the element itself + checkRefactoring("unwrap.xml", "@+id/frame"); + } + + public void testUnwrap3() throws Exception { + // Unwrap root: should transfer namespace + checkRefactoring("unwrap.xml", "@+id/linear"); + } + + private void checkRefactoring(String basename, String id) throws Exception { + IFile file = getLayoutFile(getProject(), basename); + TestContext info = setupTestContext(file, basename); + TestLayoutEditorDelegate layoutEditor = info.mLayoutEditorDelegate; + List<Element> selectedElements = getElements(info.mElement, id); + assertEquals(1, selectedElements.size()); + + UnwrapRefactoring refactoring = new UnwrapRefactoring(selectedElements, + layoutEditor); + + RefactoringStatus status = refactoring.checkInitialConditions(new NullProgressMonitor()); + assertFalse(status.hasError()); + List<Change> changes = refactoring.computeChanges(new NullProgressMonitor()); + checkEdits(basename, changes); + } +} diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/UseCompoundDrawableRefactoringTest.java b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/UseCompoundDrawableRefactoringTest.java new file mode 100644 index 000000000..01a0e1e7d --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/UseCompoundDrawableRefactoringTest.java @@ -0,0 +1,114 @@ +/* + * 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.refactoring; + +import static com.android.ide.eclipse.adt.internal.editors.layout.refactoring.UseCompoundDrawableRefactoring.combine; + +import com.android.ide.eclipse.adt.AdtUtils; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.ltk.core.refactoring.Change; +import org.eclipse.ltk.core.refactoring.CompositeChange; +import org.w3c.dom.Element; + +import java.util.List; + +@SuppressWarnings("javadoc") +public class UseCompoundDrawableRefactoringTest extends RefactoringTest { + public void testCombine() throws Exception { + assertNull(combine(null, null)); + assertNull(combine("@dimen/foo", "@dimen/bar")); + assertNull(combine("@dimen/foo", "@dimen/bar")); + assertNull(combine("1sp", "@dimen/bar")); + assertNull(combine("1sp", "2dp")); + assertNull(combine(null, "")); + assertNull(combine("", null)); + + assertEquals("@dimen/foo", combine(null, "@dimen/foo")); + assertEquals("@dimen/foo", combine("@dimen/foo", null)); + assertEquals("5sp", combine("5sp", null)); + + assertEquals("10sp", combine("8sp", "2sp")); + assertEquals("50dp", combine("30dp", "20dp")); + } + + public void test1() throws Exception { + // Test converting an image above a text view + checkRefactoring("refactoring/usecompound/compound1.xml", "@+id/layout1"); + } + + public void test2() throws Exception { + // Test converting an image below a text view + checkRefactoring("refactoring/usecompound/compound2.xml", "@+id/layout2"); + } + + public void test3() throws Exception { + // Test converting an image to the left of a text view + checkRefactoring("refactoring/usecompound/compound3.xml", "@+id/layout3"); + } + + public void test4() throws Exception { + // Test converting an image to the right of a text view + checkRefactoring("refactoring/usecompound/compound4.xml", "@+id/layout4"); + } + + public void test5() throws Exception { + // Test converting an image where the LinearLayout is referenced (in a relative layout) + // and the text view has an id + checkRefactoring("refactoring/usecompound/compound_all.xml", "@+id/layout2"); + } + + public void test6() throws Exception { + // Test converting an image where the LinearLayout is referenced (in a relative layout) + // and the text view does not have an id + checkRefactoring("refactoring/usecompound/compound_all.xml", "@+id/layout3"); + } + + public void test7() throws Exception { + // Test converting where a namespace needs to be migrated + checkRefactoring("refactoring/usecompound/compound5.xml", "@+id/layout"); + } + + public void test8() throws Exception { + // Test padding handling + checkRefactoring("refactoring/usecompound/compound6.xml", "@+id/layout1"); + } + + public void test9() throws Exception { + // Test margin combination + checkRefactoring("refactoring/usecompound/compound7.xml", "@+id/layout1"); + } + + private void checkRefactoring(String basename, String id) + throws Exception { + IFile file = getLayoutFile(getProject(), basename); + TestContext info = setupTestContext(file, basename); + TestLayoutEditorDelegate layoutEditor = info.mLayoutEditorDelegate; + List<Element> selectedElements = getElements(info.mElement, new String[] { id }); + + UseCompoundDrawableRefactoring refactoring = new UseCompoundDrawableRefactoring( + selectedElements, layoutEditor); + List<Change> changes = refactoring.computeChanges(new NullProgressMonitor()); + + CompositeChange cc = new CompositeChange("Combined from unit test", + changes.toArray(new Change[changes.size()])); + cc.markAsSynthetic(); + addCleanupDir(AdtUtils.getAbsolutePath(getProject()).toFile()); + + checkEdits(basename, changes); + } +} diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/WrapInRefactoringTest.java b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/WrapInRefactoringTest.java new file mode 100644 index 000000000..2dc6744e6 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/WrapInRefactoringTest.java @@ -0,0 +1,59 @@ +/* + * 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.refactoring; + +import static com.android.SdkConstants.FQCN_GESTURE_OVERLAY_VIEW; +import static com.android.SdkConstants.FQCN_LINEAR_LAYOUT; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.ltk.core.refactoring.Change; +import org.w3c.dom.Element; + +import java.util.List; + +public class WrapInRefactoringTest extends RefactoringTest { + + public void testWrapIn1() throws Exception { + // Test wrapping view: should indent view + checkRefactoring("sample3.xml", FQCN_LINEAR_LAYOUT, "@+id/button2"); + } + + public void testWrapIn2() throws Exception { + // Test wrapping the root: should move namespace + checkRefactoring("sample3.xml", FQCN_GESTURE_OVERLAY_VIEW, "@+id/newlinear"); + } + + public void testWrapIn3() throws Exception { + // Test wrap multiple adjacent elements - should wrap all as a unit + checkRefactoring("sample3.xml", FQCN_LINEAR_LAYOUT, "@+id/button2", "@+id/android_logo"); + } + + private void checkRefactoring(String basename, String fqcn, String... ids) throws Exception { + assertTrue(ids.length > 0); + + IFile file = getLayoutFile(getProject(), basename); + TestContext info = setupTestContext(file, basename); + TestLayoutEditorDelegate layoutEditor = info.mLayoutEditorDelegate; + List<Element> selectedElements = getElements(info.mElement, ids); + + WrapInRefactoring refactoring = new WrapInRefactoring(selectedElements, + layoutEditor); + refactoring.setType(fqcn); + List<Change> changes = refactoring.computeChanges(new NullProgressMonitor()); + checkEdits(basename, changes); + } +} diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/TestFragment.java.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/TestFragment.java.txt new file mode 100644 index 000000000..0942a19fe --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/TestFragment.java.txt @@ -0,0 +1,15 @@ +package com.android.eclipse.tests; + +import android.app.Fragment; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +public class TestFragment extends Fragment { + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + return null; + } +} diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/aapterror1.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/aapterror1.xml new file mode 100644 index 000000000..d72f4ba4c --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/aapterror1.xml @@ -0,0 +1,12 @@ +<FrameLayout + xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="wrap_content" + android:layout_height="match_parent"> + <TextView + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:layout_marginTop="50pt" + android:layout_marginLeft="50dp" + android:layout_marginBottom="50" + /> +</FrameLayout> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/aapterror2.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/aapterror2.xml new file mode 100644 index 000000000..b720daac8 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/aapterror2.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources xmlns:android="http://schemas.android.com/apk/res/android"> + <style name="repeatedStyle1"> + <item name="android:gravity">left</item> + </style> + <style name="repeatedStyle1"> + <item name="android:gravity">bottom</item> + </style> +</resources> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/aapterror3.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/aapterror3.xml new file mode 100644 index 000000000..bc9c134c7 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/aapterror3.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources xmlns:android="http://schemas.android.com/apk/res/android"> + <style name="wrongAttribute"> + <item name="nonexistent">5</item> + </style> +</resources> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/aapterror4.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/aapterror4.xml new file mode 100644 index 000000000..28dd46786 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/aapterror4.xml @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <style> + <item /> + </style> + <item></item> +</resources> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/aapterror5.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/aapterror5.xml new file mode 100644 index 000000000..ee89ac4be --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/aapterror5.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <style name="test"> + <item name="android:layout_width"></item> + </style> +</resources> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/aapterror6.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/aapterror6.xml new file mode 100644 index 000000000..e552ff797 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/aapterror6.xml @@ -0,0 +1,11 @@ +<FrameLayout + xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="wrap_content" + android:layout_height="match_parent"> + <TextView + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:layout_marginTop="" + android:layout_marginLeft='' + /> +</FrameLayout> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/aapterror7.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/aapterror7.xml new file mode 100644 index 000000000..d47f4ae83 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/aapterror7.xml @@ -0,0 +1,10 @@ +<FrameLayout + xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="wrap_content" + android:layout_height="match_parent"> + <TextView + android:id="" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + /> +</FrameLayout> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/anim1-expected-completion53.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/anim1-expected-completion53.txt new file mode 100644 index 000000000..3e44918d9 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/anim1-expected-completion53.txt @@ -0,0 +1,6 @@ +Code completion in anim1.xml for ^<set xmlns: +<alpha /> +<rotate /> +<scale /> +<set ></set> +<translate /> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/anim1-expected-completion54.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/anim1-expected-completion54.txt new file mode 100644 index 000000000..f5e5cba69 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/anim1-expected-completion54.txt @@ -0,0 +1,6 @@ +Code completion in anim1.xml for ^<translate android:id=: +<alpha /> +<rotate /> +<scale /> +<set ></set> +<translate /> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/anim1-expected-completion55.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/anim1-expected-completion55.txt new file mode 100644 index 000000000..385f4761b --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/anim1-expected-completion55.txt @@ -0,0 +1,16 @@ +Code completion in anim1.xml for android:^fromXDelta=: +android:fromXDelta : [float, fraction] +android:toXDelta : [float, fraction] +android:fromYDelta : [float, fraction] +android:toYDelta : [float, fraction] +android:interpolator : Defines the interpolator used to smooth the animation movement in time. [reference] +android:fillEnabled : When set to true, the value of fillBefore is taken into account. [boolean] +android:fillBefore : When set to true or when fillEnabled is not set to true, the animation transformation is applied before the animation has started. [boolean] +android:fillAfter : When set to true, the animation transformation is applied after the animation is over. [boolean] +android:duration : Amount of time (in milliseconds) for the animation to run. [integer] +android:startOffset : Delay in milliseconds before the animation runs, once start time is reached. [integer] +android:repeatCount : Defines how many times the animation should repeat. [integer, enum] +android:repeatMode : Defines the animation behavior when it reaches the end and the repeat count is greater than 0 or infinite. [enum] +android:zAdjustment : Allows for an adjustment of the Z ordering of the content being animated for the duration of the animation. [enum] +android:background : Special background behind animation. [color, reference] +android:detachWallpaper : Special option for window animations: if this window is on top of a wallpaper, don't animate the wallpaper with it. [boolean] diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/anim1-expected-completion56.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/anim1-expected-completion56.txt new file mode 100644 index 000000000..e12a66fa5 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/anim1-expected-completion56.txt @@ -0,0 +1,14 @@ +Code completion in anim1.xml for android:^fromAlpha=: +android:fromAlpha : [float] +android:toAlpha : [float] +android:interpolator : Defines the interpolator used to smooth the animation movement in time. [reference] +android:fillEnabled : When set to true, the value of fillBefore is taken into account. [boolean] +android:fillBefore : When set to true or when fillEnabled is not set to true, the animation transformation is applied before the animation has started. [boolean] +android:fillAfter : When set to true, the animation transformation is applied after the animation is over. [boolean] +android:duration : Amount of time (in milliseconds) for the animation to run. [integer] +android:startOffset : Delay in milliseconds before the animation runs, once start time is reached. [integer] +android:repeatCount : Defines how many times the animation should repeat. [integer, enum] +android:repeatMode : Defines the animation behavior when it reaches the end and the repeat count is greater than 0 or infinite. [enum] +android:zAdjustment : Allows for an adjustment of the Z ordering of the content being animated for the duration of the animation. [enum] +android:background : Special background behind animation. [color, reference] +android:detachWallpaper : Special option for window animations: if this window is on top of a wallpaper, don't animate the wallpaper with it. [boolean] diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/anim1-expected-completion57.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/anim1-expected-completion57.txt new file mode 100644 index 000000000..9225dac46 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/anim1-expected-completion57.txt @@ -0,0 +1,3 @@ +Code completion in anim1.xml for android:fromXDelta="100^%p": +100% : <b>Fraction</b> - a percentage of the base size +100%p : <b>Fraction</b> - a percentage relative to parent container diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/anim1.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/anim1.xml new file mode 100644 index 000000000..48fefc2ba --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/anim1.xml @@ -0,0 +1,20 @@ +<set xmlns:android="http://schemas.android.com/apk/res/android"> + <translate android:id="@+id/test1" + android:fromXDelta="100%p" + android:pivotY="60%p" + android:toXDelta="40%p" + android:toYDelta="33%p" + android:fillBefore="true" + android:fillAfter="true" + android:startOffset="1000" + android:duration="1000" /> + <alpha + android:id="@+id/test2" + android:fromAlpha="1.0" + android:toAlpha="0.0" + android:startOffset="3000" + android:duration="250" + android:fillBefore="true" + android:fillAfter="false" + /> +</set> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/animator1-expected-completion58.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/animator1-expected-completion58.txt new file mode 100644 index 000000000..075941502 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/animator1-expected-completion58.txt @@ -0,0 +1,4 @@ +Code completion in animator1.xml for ^<set xmlns: +<animator ></animator> +<objectAnimator ></objectAnimator> +<set ></set> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/animator1-expected-completion59.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/animator1-expected-completion59.txt new file mode 100644 index 000000000..474fe7761 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/animator1-expected-completion59.txt @@ -0,0 +1,10 @@ +Code completion in animator1.xml for android:^duration="2000": +android:propertyName : Name of the property being animated. [string] +android:interpolator : Defines the interpolator used to smooth the animation movement in time. [reference] +android:duration : Amount of time (in milliseconds) for the animation to run. [integer] +android:startOffset : Delay in milliseconds before the animation runs, once start time is reached. [integer] +android:repeatCount : Defines how many times the animation should repeat. [integer, enum] +android:repeatMode : Defines the animation behavior when it reaches the end and the repeat count is greater than 0 or infinite. [enum] +android:valueFrom : Value the animation starts from. [integer, float, color, dimension] +android:valueTo : Value the animation animates to. [integer, float, color, dimension] +android:valueType : The type of valueFrom and valueTo. [enum] diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/animator1-expected-completion60.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/animator1-expected-completion60.txt new file mode 100644 index 000000000..3e5e6b127 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/animator1-expected-completion60.txt @@ -0,0 +1,3 @@ +Code completion in animator1.xml for android:propertyName="scal^eX"/>: +scaleX : scale of the view in the x direction. +scaleY : scale of the view in the y direction. diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/animator1-expected-completion61.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/animator1-expected-completion61.txt new file mode 100644 index 000000000..b298ac0b4 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/animator1-expected-completion61.txt @@ -0,0 +1,19 @@ +Code completion in animator1.xml for android:interpolator="^@android:anim/bounce_interpolator": +@android:anim/accelerate_decelerate_interpolator +@android:anim/accelerate_interpolator +@android:anim/decelerate_interpolator +@android:anim/anticipate_interpolator +@android:anim/overshoot_interpolator +@android:anim/anticipate_overshoot_interpolator +@android:anim/bounce_interpolator +@android:anim/linear_interpolator +@android:anim/cycle_interpolator +@android: +@+id/ +@anim/ +@color/ +@drawable/ +@id/ +@layout/ +@string/ +@style/ diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/animator1.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/animator1.xml new file mode 100644 index 000000000..bdf10dced --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/animator1.xml @@ -0,0 +1,27 @@ +<!-- Simple bounce animation --> +<set xmlns:android="http://schemas.android.com/apk/res/android" + android:ordering="sequentially"> + <set> + <objectAnimator + android:duration="2000" + android:valueTo="310" + android:propertyName="x"/> + <objectAnimator + android:duration="2000" + android:valueTo="130" + android:propertyName="y" + android:interpolator="@android:anim/bounce_interpolator"/> + <objectAnimator + android:duration="2000" + android:valueTo=".4" + android:propertyName="scaleX"/> + <objectAnimator + android:duration="2000" + android:valueTo=".4" + android:propertyName="scaleY"/> + </set> + <objectAnimator + android:duration="500" + android:valueTo="0" + android:propertyName="alpha"/> +</set> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/broken1-expected-applyCompletion15.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/broken1-expected-applyCompletion15.diff new file mode 100644 index 000000000..4ce3540da --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/broken1-expected-applyCompletion15.diff @@ -0,0 +1,4 @@ +Code completion in broken1.xml for android:textColorHigh^ selecting android:textColorHighlight: +@@ -8 +8 +- android:textColorHigh^ ++ android:textColorHighlight="^" diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/broken1-expected-completion20.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/broken1-expected-completion20.txt new file mode 100644 index 000000000..063dc8c4b --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/broken1-expected-completion20.txt @@ -0,0 +1,2 @@ +Code completion in broken1.xml for android:textColorHigh^: +android:textColorHighlight : Color of the text selection highlight. [color, reference] diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/broken1.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/broken1.xml new file mode 100644 index 000000000..161b9818c --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/broken1.xml @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout + xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent"> + <Button + android:text="@string/app_name" + android:textColorHigh + android:layout_marginLeft="@android:dimen/app_icon_size" + android:id="@+id/button1" + ></Button> +</LinearLayout> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/broken2-expected-applyCompletion16.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/broken2-expected-applyCompletion16.diff new file mode 100644 index 000000000..3337ad265 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/broken2-expected-applyCompletion16.diff @@ -0,0 +1,4 @@ +Code completion in broken2.xml for style=^ selecting "@android:": +@@ -9 +9 +- style=^ ++ style="@android:^" diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/broken2-expected-completion21.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/broken2-expected-completion21.txt new file mode 100644 index 000000000..1ee2585cd --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/broken2-expected-completion21.txt @@ -0,0 +1,7 @@ +Code completion in broken2.xml for style=^: +"@android:" +"@+id/" +"@drawable/" +"@id/" +"@layout/" +"@string/" diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/broken2.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/broken2.xml new file mode 100644 index 000000000..60644b90c --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/broken2.xml @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout + xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent"> + <Button + android:text="@string/app_name" + android:layout_marginLeft="@android:dimen/app_icon_size" + style= + android:id="@+id/button1" + ></Button> +</LinearLayout> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/broken3-expected-applyCompletion14.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/broken3-expected-applyCompletion14.diff new file mode 100644 index 000000000..2787380ee --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/broken3-expected-applyCompletion14.diff @@ -0,0 +1,4 @@ +Code completion in broken3.xml for <EditT^ selecting EditText />: +@@ -6 +6 +- <EditT^ ++ <EditText ^/> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/broken3-expected-completion19.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/broken3-expected-completion19.txt new file mode 100644 index 000000000..ccc6a4c66 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/broken3-expected-completion19.txt @@ -0,0 +1,2 @@ +Code completion in broken3.xml for <EditT^: +EditText /> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/broken3.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/broken3.xml new file mode 100644 index 000000000..b8b168586 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/broken3.xml @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout + xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent"> + <EditT + <Button + android:text="@string/app_name" + android:layout_marginLeft="@android:dimen/app_icon_size" + android:id="@+id/button1" + ></Button> +</LinearLayout> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/color1-expected-completion45.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/color1-expected-completion45.txt new file mode 100644 index 000000000..c799b8094 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/color1-expected-completion45.txt @@ -0,0 +1,2 @@ +Code completion in color1.xml for ^<selector: +<selector ></selector> : Required. This must be the root element. Contains one or more <item> elements. diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/color1-expected-completion46a.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/color1-expected-completion46a.txt new file mode 100644 index 000000000..32f0066b6 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/color1-expected-completion46a.txt @@ -0,0 +1,2 @@ +Code completion in color1.xml for ^<item android: +<item /> : Drawable states. diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/color1-expected-completion46b.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/color1-expected-completion46b.txt new file mode 100644 index 000000000..def6d13b1 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/color1-expected-completion46b.txt @@ -0,0 +1,20 @@ +Code completion in color1.xml for <item ^android:state_focused="true"/>: +android:state_focused : State value for StateListDrawable, set when a view has input focus. [boolean] +android:state_window_focused : State value for StateListDrawable, set when a view's window has input focus. [boolean] +android:state_enabled : State value for StateListDrawable, set when a view is enabled. [boolean] +android:state_checkable : State identifier indicating that the object <var>may</var> display a check mark. [boolean] +android:state_checked : State identifier indicating that the object is currently checked. [boolean] +android:state_selected : State value for StateListDrawable, set when a view (or one of its parents) is currently selected. [boolean] +android:state_pressed : State value for StateListDrawable, set when the user is pressing down in a view. [boolean] +android:state_activated : State value for StateListDrawable, set when a view or its parent has been "activated" meaning the user has currently marked it as being of interest. [boolean] +android:state_active : State value for StateListDrawable. [boolean] +android:state_single : State value for StateListDrawable. [boolean] +android:state_first : State value for StateListDrawable. [boolean] +android:state_middle : State value for StateListDrawable. [boolean] +android:state_last : State value for StateListDrawable. [boolean] +android:state_accelerated : State value for StateListDrawable, indicating that the Drawable is in a view that is hardware accelerated. [boolean] +android:state_hovered : State value for StateListDrawable, set when a pointer is hovering over the view. [boolean] +android:state_drag_can_accept : State for StateListDrawable indicating that the Drawable is in a view that is capable of accepting a drop of the content currently being manipulated in a drag-and-drop operation. [boolean] +android:state_drag_hovered : State for StateListDrawable indicating that a drag operation (for which the Drawable's view is a valid recipient) is currently positioned over the Drawable. [boolean] +android:state_accessibility_focused : State for StateListDrawable indicating that a View has accessibility focus. [boolean] +android:color : Hexadeximal color. Required. The color is specified with an RGB value and optional alpha channel. The value always begins with a pound (#) character and then followed by the Alpha-Red-Green-Blue information in one of the following formats: * RGB * ARGB * RRGGBB * AARRGGBB diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/color1.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/color1.xml new file mode 100644 index 000000000..a8482abac --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/color1.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8"?> +<selector + xmlns:android="http://schemas.android.com/apk/res/android"> + <item android:state_focused="true"/> + <item /> +</selector> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-actual-applyCompletion1.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-actual-applyCompletion1.xml new file mode 100644 index 000000000..2413658a7 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-actual-applyCompletion1.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"> +<!-- + This file deliberately contains errors - it represents partial keyboard + typing for interactive code completion +--> + <TextView + android:layout_weight^="fill_parent" + android:layout_height="wrap_content" + android:layout_marginTop="@android:dimen/app_icon_size" + android:layout_marginLeft="50dp" + android:layout_marginBottom="50" + android:textColor="#000000" + style="@android:style/Widget.Button" + android:gravity="left|bottom" + android:text="@string/hello" + android:hint="hint" /> + <FrameLayout android:foreground="@android:drawable/btn_default"></FrameLayout> +</LinearLayout> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-applyCompletion1.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-applyCompletion1.diff new file mode 100644 index 000000000..6b0556615 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-applyCompletion1.diff @@ -0,0 +1,4 @@ +Code completion in completion1.xml for layout_w^idth="fill_parent" selecting android:layout_weight: +@@ -8 +8 +- android:layout_w^idth="fill_parent" ++ android:layout_weight^="fill_parent" diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-applyCompletion10.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-applyCompletion10.diff new file mode 100644 index 000000000..7b448c29f --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-applyCompletion10.diff @@ -0,0 +1,4 @@ +Code completion in completion1.xml for <T^extView selecting TableLayout: +@@ -7 +7 +- <T^extView ++ <TableLayout^ diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-applyCompletion11a.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-applyCompletion11a.diff new file mode 100644 index 000000000..1a5f24d6c --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-applyCompletion11a.diff @@ -0,0 +1,4 @@ +Code completion in completion1.xml for ^<TextView selecting <RadioGroup ></RadioGroup>: +@@ -7 +7 +- ^<TextView ++ <RadioGroup ^></RadioGroup><TextView diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-applyCompletion11b.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-applyCompletion11b.diff new file mode 100644 index 000000000..9010bf60c --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-applyCompletion11b.diff @@ -0,0 +1,4 @@ +Code completion in completion1.xml for ^<TextView selecting <CheckBox />: +@@ -7 +7 +- ^<TextView ++ <CheckBox ^/><TextView diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-applyCompletion12.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-applyCompletion12.diff new file mode 100644 index 000000000..a7a463877 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-applyCompletion12.diff @@ -0,0 +1,4 @@ +Code completion in completion1.xml for btn_default">^</FrameLayout> selecting <FrameLayout ></FrameLayout>: +@@ -18 +18 +- <FrameLayout android:foreground="@android:drawable/btn_default">^</FrameLayout> ++ <FrameLayout android:foreground="@android:drawable/btn_default"><FrameLayout ^></FrameLayout></FrameLayout> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-applyCompletion2.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-applyCompletion2.diff new file mode 100644 index 000000000..77761316d --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-applyCompletion2.diff @@ -0,0 +1,4 @@ +Code completion in completion1.xml for layout_width="^fill_parent" selecting match_parent: +@@ -8 +8 +- android:layout_width="^fill_parent" ++ android:layout_width="match_parent"^ diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-applyCompletion3.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-applyCompletion3.diff new file mode 100644 index 000000000..e67a3369d --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-applyCompletion3.diff @@ -0,0 +1,4 @@ +Code completion in completion1.xml for layout_width="fi^ll_parent" selecting fill_parent: +@@ -8 +8 +- android:layout_width="fi^ll_parent" ++ android:layout_width="fill_parent"^ diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-applyCompletion39.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-applyCompletion39.diff new file mode 100644 index 000000000..fe63acd22 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-applyCompletion39.diff @@ -0,0 +1,4 @@ +Code completion in completion1.xml for marginBottom="50"^ selecting android:maxEms: +@@ -12 +12 +- android:layout_marginBottom="50"^ ++ android:layout_marginBottom="50" android:maxEms="^" diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-applyCompletion4.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-applyCompletion4.diff new file mode 100644 index 000000000..2d229f3c4 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-applyCompletion4.diff @@ -0,0 +1,4 @@ +Code completion in completion1.xml for marginBottom="50^" selecting 50mm: +@@ -12 +12 +- android:layout_marginBottom="50^" ++ android:layout_marginBottom="50mm"^ diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-applyCompletion5.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-applyCompletion5.diff new file mode 100644 index 000000000..5a2b413d1 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-applyCompletion5.diff @@ -0,0 +1,4 @@ +Code completion in completion1.xml for layout_marginLeft="50d^p" selecting 50dp: +@@ -11 +11 +- android:layout_marginLeft="50d^p" ++ android:layout_marginLeft="50dp"^ diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-applyCompletion6.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-applyCompletion6.diff new file mode 100644 index 000000000..d3a8c1120 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-applyCompletion6.diff @@ -0,0 +1,4 @@ +Code completion in completion1.xml for style="@android:^style/Widget.Button" selecting @android:drawable/: +@@ -14 +14 +- style="@android:^style/Widget.Button" ++ style="@android:drawable/^" diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-applyCompletion7a.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-applyCompletion7a.diff new file mode 100644 index 000000000..afd7e21e0 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-applyCompletion7a.diff @@ -0,0 +1,4 @@ +Code completion in completion1.xml for android:gravity="l^eft|bottom" selecting left: +@@ -15 +15 +- android:gravity="l^eft|bottom" ++ android:gravity="left^" diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-applyCompletion7b.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-applyCompletion7b.diff new file mode 100644 index 000000000..73f2bd48a --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-applyCompletion7b.diff @@ -0,0 +1,4 @@ +Code completion in completion1.xml for android:gravity="left|b^ottom" selecting bottom: +@@ -15 +15 +- android:gravity="left|b^ottom" ++ android:gravity="left|bottom^" diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-applyCompletion8.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-applyCompletion8.diff new file mode 100644 index 000000000..655afc529 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-applyCompletion8.diff @@ -0,0 +1,2 @@ +Code completion in completion1.xml for layout_width^="fill_parent" selecting android:layout_width: +No changes
\ No newline at end of file diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-applyCompletion9.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-applyCompletion9.diff new file mode 100644 index 000000000..1b4198e43 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-applyCompletion9.diff @@ -0,0 +1,4 @@ +Code completion in completion1.xml for layout_width=^"fill_parent" selecting "wrap_content": +@@ -8 +8 +- android:layout_width=^"fill_parent" ++ android:layout_width="wrap_content"^ diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-completion1.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-completion1.txt new file mode 100644 index 000000000..c3e75ad54 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-completion1.txt @@ -0,0 +1,3 @@ +Code completion in completion1.xml for layout_w^idth="fill_parent": +android:layout_width : Specifies the basic width of the view. [dimension, enum] +android:layout_weight : [float] diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-completion10.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-completion10.txt new file mode 100644 index 000000000..973d95eff --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-completion10.txt @@ -0,0 +1,11 @@ +Code completion in completion1.xml for <T^extView: +TabHost +TabWidget +TableLayout +TableRow +TextSwitcher +TextView +TextureView +TimePicker +ToggleButton +TwoLineListItem diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-completion11.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-completion11.txt new file mode 100644 index 000000000..20dad3a53 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-completion11.txt @@ -0,0 +1,67 @@ +Code completion in completion1.xml for ^<TextView: +<AbsoluteLayout ></AbsoluteLayout> +<AdapterViewFlipper ></AdapterViewFlipper> +<AnalogClock /> +<AutoCompleteTextView /> +<Button /> +<CalendarView /> +<CheckBox /> +<CheckedTextView /> +<Chronometer /> +<DatePicker /> +<DialerFilter ></DialerFilter> +<DigitalClock /> +<EditText /> +<ExpandableListView ></ExpandableListView> +<FrameLayout ></FrameLayout> +<Gallery /> +<GridLayout ></GridLayout> +<GridView ></GridView> +<HorizontalScrollView ></HorizontalScrollView> +<ImageButton /> +<ImageSwitcher ></ImageSwitcher> +<ImageView /> +<LinearLayout ></LinearLayout> +<ListView ></ListView> +<MediaController ></MediaController> +<MultiAutoCompleteTextView /> +<NumberPicker /> +<ProgressBar /> +<QuickContactBadge /> +<RadioButton /> +<RadioGroup ></RadioGroup> +<RatingBar /> +<RelativeLayout ></RelativeLayout> +<ScrollView ></ScrollView> +<SearchView ></SearchView> +<SeekBar /> +<SlidingDrawer ></SlidingDrawer> : SlidingDrawer specific attributes. +<Space /> +<Spinner /> +<StackView ></StackView> +<SurfaceView /> +<Switch /> +<TabHost ></TabHost> +<TabWidget ></TabWidget> +<TableLayout ></TableLayout> +<TableRow ></TableRow> +<TextSwitcher ></TextSwitcher> +<TextView /> +<TextureView /> +<TimePicker /> +<ToggleButton /> +<TwoLineListItem /> +<VideoView /> +<View /> : Attributes that can be used with android.view.View or any of its subclasses. +<ViewAnimator ></ViewAnimator> +<ViewFlipper ></ViewFlipper> +<ViewStub /> : A android.view.ViewStub lets you lazily include other XML layouts inside your application at runtime. +<ViewSwitcher ></ViewSwitcher> +<WebView /> +<ZoomButton /> +<ZoomControls /> +<android.gesture.GestureOverlayView ></android.gesture.GestureOverlayView> : GestureOverlayView specific attributes. +<fragment /> : A Fragment is a piece of an application's user interface or behavior that can be placed in an Activity +<include /> : Lets you statically include XML layouts inside other XML layouts. +<requestFocus /> : Requests focus for the parent element or one of its descendants +<view /> : A view tag whose class attribute names the class to be instantiated diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-completion12.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-completion12.txt new file mode 100644 index 000000000..8da18db43 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-completion12.txt @@ -0,0 +1,67 @@ +Code completion in completion1.xml for btn_default">^</FrameLayout>: +<AbsoluteLayout ></AbsoluteLayout> +<AdapterViewFlipper ></AdapterViewFlipper> +<AnalogClock /> +<AutoCompleteTextView /> +<Button /> +<CalendarView /> +<CheckBox /> +<CheckedTextView /> +<Chronometer /> +<DatePicker /> +<DialerFilter ></DialerFilter> +<DigitalClock /> +<EditText /> +<ExpandableListView ></ExpandableListView> +<FrameLayout ></FrameLayout> +<Gallery /> +<GridLayout ></GridLayout> +<GridView ></GridView> +<HorizontalScrollView ></HorizontalScrollView> +<ImageButton /> +<ImageSwitcher ></ImageSwitcher> +<ImageView /> +<LinearLayout ></LinearLayout> +<ListView ></ListView> +<MediaController ></MediaController> +<MultiAutoCompleteTextView /> +<NumberPicker /> +<ProgressBar /> +<QuickContactBadge /> +<RadioButton /> +<RadioGroup ></RadioGroup> +<RatingBar /> +<RelativeLayout ></RelativeLayout> +<ScrollView ></ScrollView> +<SearchView ></SearchView> +<SeekBar /> +<SlidingDrawer ></SlidingDrawer> : SlidingDrawer specific attributes. +<Space /> +<Spinner /> +<StackView ></StackView> +<SurfaceView /> +<Switch /> +<TabHost ></TabHost> +<TabWidget ></TabWidget> +<TableLayout ></TableLayout> +<TableRow ></TableRow> +<TextSwitcher ></TextSwitcher> +<TextView /> +<TextureView /> +<TimePicker /> +<ToggleButton /> +<TwoLineListItem /> +<VideoView /> +<View /> : Attributes that can be used with android.view.View or any of its subclasses. +<ViewAnimator ></ViewAnimator> +<ViewFlipper ></ViewFlipper> +<ViewStub /> : A android.view.ViewStub lets you lazily include other XML layouts inside your application at runtime. +<ViewSwitcher ></ViewSwitcher> +<WebView /> +<ZoomButton /> +<ZoomControls /> +<android.gesture.GestureOverlayView ></android.gesture.GestureOverlayView> : GestureOverlayView specific attributes. +<fragment /> : A Fragment is a piece of an application's user interface or behavior that can be placed in an Activity +<include /> : Lets you statically include XML layouts inside other XML layouts. +<requestFocus /> : Requests focus for the parent element or one of its descendants +<view /> : A view tag whose class attribute names the class to be instantiated diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-completion2.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-completion2.txt new file mode 100644 index 000000000..136a6fe4d --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-completion2.txt @@ -0,0 +1,4 @@ +Code completion in completion1.xml for layout_width="^fill_parent": +fill_parent +match_parent +wrap_content diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-completion3.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-completion3.txt new file mode 100644 index 000000000..09c27ce2d --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-completion3.txt @@ -0,0 +1,2 @@ +Code completion in completion1.xml for layout_width="fi^ll_parent": +fill_parent diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-completion39.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-completion39.txt new file mode 100644 index 000000000..2ac2d3186 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-completion39.txt @@ -0,0 +1,156 @@ +Code completion in completion1.xml for marginBottom="50"^: +style : A reference to a custom style [reference] +android:bufferType : Determines the minimum type that getText() will return. [enum] +android:text : Text to display. [string] +android:hint : Hint text to display when the text is empty. [string] +android:textColor : Text color. [color, reference] +android:textColorHighlight : Color of the text selection highlight. [color, reference] +android:textColorHint : Color of the hint text. [color, reference] +android:textAppearance : Base text color, typeface, size, and style. [reference] +android:textSize : Size of the text. [dimension] +android:textScaleX : Sets the horizontal scaling factor for the text. [float] +android:typeface : Typeface (normal, sans, serif, monospace) for the text. [enum] +android:textStyle : Style (bold, italic, bolditalic) for the text. [flag] +android:fontFamily : Font family (named by string) for the text. [string] +android:textColorLink : Text color for links. [color, reference] +android:cursorVisible : Makes the cursor visible (the default) or invisible. [boolean] +android:maxLines : Makes the TextView be at most this many lines tall. [integer] +android:maxHeight : Makes the TextView be at most this many pixels tall. [dimension] +android:lines : Makes the TextView be exactly this many lines tall. [integer] +android:height : Makes the TextView be exactly this many pixels tall. [dimension] +android:minLines : Makes the TextView be at least this many lines tall. [integer] +android:minHeight : Makes the TextView be at least this many pixels tall. [dimension] +android:maxEms : Makes the TextView be at most this many ems wide. [integer] +android:maxWidth : Makes the TextView be at most this many pixels wide. [dimension] +android:ems : Makes the TextView be exactly this many ems wide. [integer] +android:width : Makes the TextView be exactly this many pixels wide. [dimension] +android:minEms : Makes the TextView be at least this many ems wide. [integer] +android:minWidth : Makes the TextView be at least this many pixels wide. [dimension] +android:gravity : Specifies how to align the text by the view's x- and/or y-axis when the text is smaller than the view. [flag] +android:scrollHorizontally : Whether the text is allowed to be wider than the view (and therefore can be scrolled horizontally). [boolean] +android:password : Whether the characters of the field are displayed as password dots instead of themselves. * Deprecated: Use inputType instead. [boolean] +android:singleLine : Constrains the text to a single horizontally scrolling line instead of letting it wrap onto multiple lines, and advances focus instead of inserting a newline when you press the enter key. * Deprecated: This attribute is deprecated. Use "maxLines" instead to change the layo... +android:enabled : Specifies whether the widget is enabled. [boolean] +android:selectAllOnFocus : If the text is selectable, select it all when the view takes focus. [boolean] +android:includeFontPadding : Leave enough room for ascenders and descenders instead of using the font ascent and descent strictly. [boolean] +android:maxLength : Set an input filter to constrain the text length to the specified number. [integer] +android:shadowColor : Place a shadow of the specified color behind the text. [color] +android:shadowDx : Horizontal offset of the shadow. [float] +android:shadowDy : Vertical offset of the shadow. [float] +android:shadowRadius : Radius of the shadow. [float] +android:autoLink : Controls whether links such as urls and email addresses are automatically found and converted to clickable links. [flag] +android:linksClickable : If set to false, keeps the movement method from being set to the link movement method even if autoLink causes links to be found. [boolean] +android:numeric : If set, specifies that this TextView has a numeric input method. * Deprecated: Use inputType instead. [flag] +android:digits : If set, specifies that this TextView has a numeric input method and that these specific characters are the ones that it will accept. [string] +android:phoneNumber : If set, specifies that this TextView has a phone number input method. * Deprecated: Use inputType instead. [boolean] +android:inputMethod : If set, specifies that this TextView should use the specified input method (specified by fully-qualified class name). * Deprecated: Use inputType instead. [string] +android:capitalize : If set, specifies that this TextView has a textual input method and should automatically capitalize what the user types. * Deprecated: Use inputType instead. [enum] +android:autoText : If set, specifies that this TextView has a textual input method and automatically corrects some common spelling errors. * Deprecated: Use inputType instead. [boolean] +android:editable : If set, specifies that this TextView has an input method. * Deprecated: Use inputType instead. [boolean] +android:freezesText : If set, the text view will include its current complete text inside of its frozen icicle in addition to meta-data such as the current cursor position. [boolean] +android:ellipsize : If set, causes words that are longer than the view is wide to be ellipsized instead of broken in the middle. [enum] +android:drawableTop : The drawable to be drawn above the text. [color, reference] +android:drawableBottom : The drawable to be drawn below the text. [color, reference] +android:drawableLeft : The drawable to be drawn to the left of the text. [color, reference] +android:drawableRight : The drawable to be drawn to the right of the text. [color, reference] +android:drawableStart : The drawable to be drawn to the start of the text. [color, reference] +android:drawableEnd : The drawable to be drawn to the end of the text. [color, reference] +android:drawablePadding : The padding between the drawables and the text. [dimension] +android:lineSpacingExtra : Extra spacing between lines of text. [dimension] +android:lineSpacingMultiplier : Extra spacing between lines of text, as a multiplier. [float] +android:marqueeRepeatLimit : The number of times to repeat the marquee animation. [integer, enum] +android:inputType : The type of data being placed in a text field, used to help an input method decide how to let the user enter text. [flag] +android:imeOptions : Additional features you can enable in an IME associated with an editor to improve the integration with your application. [flag] +android:privateImeOptions : An addition content type description to supply to the input method attached to the text view, which is private to the implementation of the input method. [string] +android:imeActionLabel : Supply a value for EditorInfo.actionLabel used when an input method is connected to the text view. [string] +android:imeActionId : Supply a value for EditorInfo.actionId used when an input method is connected to the text view. [integer] +android:editorExtras : Reference to an "input-extras" XML resource containing additional data to supply to an input method, which is private to the implementation of the input method. [reference] +android:textSelectHandleLeft : Reference to a drawable that will be used to display a text selection anchor on the left side of a selection region. [reference] +android:textSelectHandleRight : Reference to a drawable that will be used to display a text selection anchor on the right side of a selection region. [reference] +android:textSelectHandle : Reference to a drawable that will be used to display a text selection anchor for positioning the cursor within text. [reference] +android:textEditPasteWindowLayout : The layout of the view that is displayed on top of the cursor to paste inside a TextEdit field. [reference] +android:textEditNoPasteWindowLayout : Variation of textEditPasteWindowLayout displayed when the clipboard is empty. [reference] +android:textEditSidePasteWindowLayout : Used instead of textEditPasteWindowLayout when the window is moved on the side of the insertion cursor because it would be clipped if it were positioned on top. [reference] +android:textEditSideNoPasteWindowLayout : Variation of textEditSidePasteWindowLayout displayed when the clipboard is empty. [reference] +android:textEditSuggestionItemLayout : Layout of the TextView item that will populate the suggestion popup window. [reference] +android:textCursorDrawable : Reference to a drawable that will be drawn under the insertion cursor. [reference] +android:textIsSelectable : Indicates that the content of a non-editable text can be selected. [boolean] +android:textAllCaps : Present the text in ALL CAPS. [boolean] +android:id : Supply an identifier name for this view, to later retrieve it with View.findViewById() or Activity.findViewById(). [reference] +android:tag : Supply a tag for this view containing a String, to be retrieved later with View.getTag() or searched for with View.findViewWithTag() . [string] +android:scrollX : The initial horizontal scroll offset, in pixels. [dimension] +android:scrollY : The initial vertical scroll offset, in pixels. [dimension] +android:background : A drawable to use as the background. [color, reference] +android:padding : Sets the padding, in pixels, of all four edges. [dimension] +android:paddingLeft : Sets the padding, in pixels, of the left edge; see padding. [dimension] +android:paddingTop : Sets the padding, in pixels, of the top edge; see padding. [dimension] +android:paddingRight : Sets the padding, in pixels, of the right edge; see padding. [dimension] +android:paddingBottom : Sets the padding, in pixels, of the bottom edge; see padding. [dimension] +android:paddingStart : Sets the padding, in pixels, of the start edge; see padding. [dimension] +android:paddingEnd : Sets the padding, in pixels, of the end edge; see padding. [dimension] +android:focusable : Boolean that controls whether a view can take focus. [boolean] +android:focusableInTouchMode : Boolean that controls whether a view can take focus while in touch mode. [boolean] +android:visibility : Controls the initial visibility of the view. [enum] +android:fitsSystemWindows : Boolean internal attribute to adjust view layout based on system windows such as the status bar. [boolean] +android:scrollbars : Defines which scrollbars should be displayed on scrolling or not. [flag] +android:scrollbarStyle : Controls the scrollbar style and position. [enum] +android:isScrollContainer : Set this if the view will serve as a scrolling container, meaing that it can be resized to shrink its overall window so that there will be space for an input method. [boolean] +android:fadeScrollbars : Defines whether to fade out scrollbars when they are not in use. [boolean] +android:scrollbarFadeDuration : Defines the delay in milliseconds that a scrollbar takes to fade out. [integer] +android:scrollbarDefaultDelayBeforeFade : Defines the delay in milliseconds that a scrollbar waits before fade out. [integer] +android:scrollbarSize : Sets the width of vertical scrollbars and height of horizontal scrollbars. [dimension] +android:scrollbarThumbHorizontal : Defines the horizontal scrollbar thumb drawable. [reference] +android:scrollbarThumbVertical : Defines the vertical scrollbar thumb drawable. [reference] +android:scrollbarTrackHorizontal : Defines the horizontal scrollbar track drawable. [reference] +android:scrollbarTrackVertical : Defines the vertical scrollbar track drawable. [reference] +android:scrollbarAlwaysDrawHorizontalTrack : Defines whether the horizontal scrollbar track should always be drawn. [boolean] +android:scrollbarAlwaysDrawVerticalTrack : Defines whether the vertical scrollbar track should always be drawn. [boolean] +android:fadingEdge : This attribute is deprecated and will be ignored as of API level 14 (ICE_CREAM_SANDWICH). [flag] +android:requiresFadingEdge : Defines which edges should be faded on scrolling. [flag] +android:fadingEdgeLength : Defines the length of the fading edges. [dimension] +android:nextFocusLeft : Defines the next view to give focus to when the next focus is FOCUS_LEFT. [reference] +android:nextFocusRight : Defines the next view to give focus to when the next focus is FOCUS_RIGHT If the reference refers to a view that does not exist or is part of a hierarchy that is invisible, a java.lang.RuntimeException will result when the reference is accessed. [reference] +android:nextFocusUp : Defines the next view to give focus to when the next focus is FOCUS_UP If the reference refers to a view that does not exist or is part of a hierarchy that is invisible, a java.lang.RuntimeException will result when the reference is accessed. [reference] +android:nextFocusDown : Defines the next view to give focus to when the next focus is FOCUS_DOWN If the reference refers to a view that does not exist or is part of a hierarchy that is invisible, a java.lang.RuntimeException will result when the reference is accessed. [reference] +android:nextFocusForward : Defines the next view to give focus to when the next focus is FOCUS_FORWARD If the reference refers to a view that does not exist or is part of a hierarchy that is invisible, a java.lang.RuntimeException will result when the reference is accessed. [reference] +android:clickable : Defines whether this view reacts to click events. [boolean] +android:longClickable : Defines whether this view reacts to long click events. [boolean] +android:saveEnabled : If unset, no state will be saved for this view when it is being frozen. [boolean] +android:filterTouchesWhenObscured : Specifies whether to filter touches when the view's window is obscured by another visible window. [boolean] +android:drawingCacheQuality : Defines the quality of translucent drawing caches. [enum] +android:keepScreenOn : Controls whether the view's window should keep the screen on while visible. [boolean] +android:duplicateParentState : When this attribute is set to true, the view gets its drawable state (focused, pressed, etc.) from its direct parent rather than from itself. [boolean] +android:minHeight : Defines the minimum height of the view. +android:minWidth : Defines the minimum width of the view. +android:soundEffectsEnabled : Boolean that controls whether a view should have sound effects enabled for events such as clicking and touching. [boolean] +android:hapticFeedbackEnabled : Boolean that controls whether a view should have haptic feedback enabled for events such as long presses. [boolean] +android:contentDescription : Defines text that briefly describes content of the view. [string] +android:onClick : Name of the method in this View's context to invoke when the view is clicked. [string] +android:overScrollMode : Defines over-scrolling behavior. [enum] +android:alpha : alpha property of the view, as a value between 0 (completely transparent) and 1 (completely opaque). [float] +android:translationX : translation in x of the view. [dimension] +android:translationY : translation in y of the view. [dimension] +android:transformPivotX : x location of the pivot point around which the view will rotate and scale. [dimension] +android:transformPivotY : y location of the pivot point around which the view will rotate and scale. [dimension] +android:rotation : rotation of the view, in degrees. [float] +android:rotationX : rotation of the view around the x axis, in degrees. [float] +android:rotationY : rotation of the view around the y axis, in degrees. [float] +android:scaleX : scale of the view in the x direction. [float] +android:scaleY : scale of the view in the y direction. [float] +android:verticalScrollbarPosition : Determines which side the vertical scroll bar should be placed on. [enum] +android:layerType : Specifies the type of layer backing this view. [enum] +android:layoutDirection : Defines the direction of layout drawing. [enum] +android:textDirection : Direction of the text. [integer, enum] +android:textAlignment : Alignment of the text. [integer, enum] +android:importantForAccessibility : Controls how this View is important for accessibility which is if it fires accessibility events and if it is reported to accessibility services that query the screen. [integer, enum] +android:layout_width : Specifies the basic width of the view. [dimension, enum] +android:layout_height : Specifies the basic height of the view. [dimension, enum] +android:layout_weight : [float] +android:layout_gravity : Standard gravity constant that a child can supply to its parent. [flag] +android:layout_margin : Specifies extra space on the left, top, right and bottom sides of this view. [dimension] +android:layout_marginLeft : Specifies extra space on the left side of this view. [dimension] +android:layout_marginTop : Specifies extra space on the top side of this view. [dimension] +android:layout_marginRight : Specifies extra space on the right side of this view. [dimension] +android:layout_marginBottom : Specifies extra space on the bottom side of this view. [dimension] +android:layout_marginStart : Specifies extra space on the start side of this view. [dimension] +android:layout_marginEnd : Specifies extra space on the end side of this view. [dimension] diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-completion4.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-completion4.txt new file mode 100644 index 000000000..a9111eb31 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-completion4.txt @@ -0,0 +1,7 @@ +Code completion in completion1.xml for marginBottom="50^": +50dp : <b>Density-independent Pixels</b> - an abstract unit that is based on the physical density of the screen. +50sp : <b>Scale-independent Pixels</b> - this is like the dp unit, but it is also scaled by the user's font size preference. +50pt : <b>Points</b> - 1/72 of an inch based on the physical size of the screen. +50mm : <b>Millimeters</b> - based on the physical size of the screen. +50in : <b>Inches</b> - based on the physical size of the screen. +50px : <b>Pixels</b> - corresponds to actual pixels on the screen. Not recommended. diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-completion5.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-completion5.txt new file mode 100644 index 000000000..6b1c99363 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-completion5.txt @@ -0,0 +1,2 @@ +Code completion in completion1.xml for layout_marginLeft="50d^p": +50dp : <b>Density-independent Pixels</b> - an abstract unit that is based on the physical density of the screen. diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-completion6.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-completion6.txt new file mode 100644 index 000000000..99f92b8f3 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-completion6.txt @@ -0,0 +1,23 @@ +Code completion in completion1.xml for style="@android:^style/Widget.Button": +@android:style/ +@android:anim/ +@android:animator/ +@android:array/ +@android:attr/ +@android:bool/ +@android:color/ +@android:declare-styleable/ +@android:dimen/ +@android:drawable/ +@android:fraction/ +@android:id/ +@android:integer/ +@android:interpolator/ +@android:layout/ +@android:menu/ +@android:mipmap/ +@android:plurals/ +@android:public/ +@android:raw/ +@android:string/ +@android:xml/ diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-completion7a.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-completion7a.txt new file mode 100644 index 000000000..cf373adde --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-completion7a.txt @@ -0,0 +1,2 @@ +Code completion in completion1.xml for android:gravity="l^eft|bottom": +left diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-completion7b.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-completion7b.txt new file mode 100644 index 000000000..66276d628 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-completion7b.txt @@ -0,0 +1,2 @@ +Code completion in completion1.xml for android:gravity="left|b^ottom": +bottom diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-completion8.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-completion8.txt new file mode 100644 index 000000000..a364bc3ff --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-completion8.txt @@ -0,0 +1,2 @@ +Code completion in completion1.xml for layout_width^="fill_parent": +android:layout_width : Specifies the basic width of the view. [dimension, enum] diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-completion9.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-completion9.txt new file mode 100644 index 000000000..ab6a0d249 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1-expected-completion9.txt @@ -0,0 +1,4 @@ +Code completion in completion1.xml for layout_width=^"fill_parent": +"fill_parent" +"match_parent" +"wrap_content" diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1.xml new file mode 100644 index 000000000..d523eeb3d --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion1.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"> +<!-- + This file deliberately contains errors - it represents partial keyboard + typing for interactive code completion +--> + <TextView + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:layout_marginTop="@android:dimen/app_icon_size" + android:layout_marginLeft="50dp" + android:layout_marginBottom="50" + android:textColor="#000000" + style="@android:style/Widget.Button" + android:gravity="left|bottom" + android:text="@string/hello" + android:hint="hint" /> + <FrameLayout android:foreground="@android:drawable/btn_default"></FrameLayout> +</LinearLayout> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion10-expected-applyCompletion42.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion10-expected-applyCompletion42.diff new file mode 100644 index 000000000..af28a1343 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion10-expected-applyCompletion42.diff @@ -0,0 +1,4 @@ +Code completion in completion10.xml for "[^wrap_content]" selecting fill_parent: +@@ -9 +9 +- android:layout_height="^wrap_content"/> ++ android:layout_height="fill_parent"^/> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion10-expected-applyCompletion43.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion10-expected-applyCompletion43.diff new file mode 100644 index 000000000..0a4d338e2 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion10-expected-applyCompletion43.diff @@ -0,0 +1,4 @@ +Code completion in completion10.xml for "[^wrap_c]ontent" selecting fill_parent: +@@ -9 +9 +- android:layout_height="^wrap_content"/> ++ android:layout_height="fill_parent"^/> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion10-expected-completion65.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion10-expected-completion65.txt new file mode 100644 index 000000000..69fae0da3 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion10-expected-completion65.txt @@ -0,0 +1,4 @@ +Code completion in completion10.xml for "[^wrap_content]": +fill_parent +match_parent +wrap_content diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion10.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion10.xml new file mode 100644 index 000000000..57b38ee11 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion10.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="utf-8"?> +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:gravity="center_vertical"> +<Gallery xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/gallery" + android:layout_width="fill_parent" + android:layout_height="wrap_content"/> +</RelativeLayout> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion11-expected-applyCompletion46.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion11-expected-applyCompletion46.diff new file mode 100644 index 000000000..321deaa46 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion11-expected-applyCompletion46.diff @@ -0,0 +1,4 @@ +Code completion in completion11.xml for ?android:attr/Textapp^ selecting ?android:attr/textAppearanceLargeInverse: +@@ -7 +7 +- style="?android:attr/Textapp^" ++ style="?android:attr/textAppearanceLargeInverse^" diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion11-expected-complation79.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion11-expected-complation79.txt new file mode 100644 index 000000000..3748c77ec --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion11-expected-complation79.txt @@ -0,0 +1,10 @@ +Code completion in completion11.xml for tools:context="^.MainActivity": +android.accounts.AccountAuthenticatorActivity : <p>See <code><a href="/reference/android/app/SearchManager.html">android.app.SearchManager</a></code> for more details.</td> </tr> <tr class=" api apilevel-1" > <td class="jd-typecol">int</td> <td class="jd-linkcol"... +android.app.ActivityGroup : <p> <p class="caution"> <strong>This class was deprecated in API level 13</strong>.<br/> Use the new <code><a href="/reference/android/app/Fragment.html">Fragment</a></code> and <code><a href="/reference/android/app/FragmentManager.html">FragmentManager</... +android.app.AliasActivity : <p>See <code><a href="/reference/android/app/SearchManager.html">android.app.SearchManager</a></code> for more details.</td> </tr> <tr class=" api apilevel-1" > <td class="jd-typecol">int</td> <td class="jd-linkcol"><a href="/reference... +android.app.ExpandableListActivity : <p> ExpandableListActivity hosts a <code><a href="/reference/android/widget/ExpandableListView.html">ExpandableListView</a></code> object that can be bound to different data sources that provide a two-levels of data (the top-level is group, and below each ... +android.app.LauncherActivity : <div id="jd-header"> public abstract class <h1 itemprop="name">LauncherActivity</h1> extends <a href="/reference/android/app/ListActivity.html">ListActivity</a><br/> ... +android.app.ListActivity : <p> ListActivity hosts a <code><a href="/reference/android/widget/ListView.html">ListView</a></code> object that can be bound to different data sources, typically either an array or a Cursor holding query results. Binding, screen layout, and row layout are discussed ... +android.app.NativeActivity : <p>A typical manifest would look like: <pre><manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.native_activity" android:versionCode="1" android:versionName="1.0"> <!-- This is the platform ... +android.app.TabActivity : <p> <p class="caution"> <strong>This class was deprecated in API level 13</strong>.<br/> New applications should use Fragments instead of this class; to continue to run on older devices, you can use the v4 support library which provides a version of the F... +android.preference.PreferenceActivity : <p>This activity shows one or more headers of preferences, each of which is associated with a <code><a href="/reference/android/preference/PreferenceFragment.html">PreferenceFragment</a></code> to display the preferences of that header. The actual layout... diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion11-expected-completion72.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion11-expected-completion72.txt new file mode 100644 index 000000000..e4c21f9a4 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion11-expected-completion72.txt @@ -0,0 +1,3 @@ +Code completion in completion11.xml for ?^android:attr/Textapp: +?android:attr/ +?attr/ diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion11-expected-completion73.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion11-expected-completion73.txt new file mode 100644 index 000000000..04cbbce93 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion11-expected-completion73.txt @@ -0,0 +1,16 @@ +Code completion in completion11.xml for ?android:attr/Textapp^: +?android:attr/textAppearance : Base text color, typeface, size, and style. +?android:attr/textAppearanceButton +?android:attr/textAppearanceInverse +?android:attr/textAppearanceLarge +?android:attr/textAppearanceLargeInverse +?android:attr/textAppearanceLargePopupMenu +?android:attr/textAppearanceListItem +?android:attr/textAppearanceListItemSmall +?android:attr/textAppearanceMedium +?android:attr/textAppearanceMediumInverse +?android:attr/textAppearanceSearchResultSubtitle +?android:attr/textAppearanceSearchResultTitle +?android:attr/textAppearanceSmall +?android:attr/textAppearanceSmallInverse +?android:attr/textAppearanceSmallPopupMenu diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion11-expected-completion74.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion11-expected-completion74.txt new file mode 100644 index 000000000..9579c93db --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion11-expected-completion74.txt @@ -0,0 +1,2 @@ +Code completion in completion11.xml for ?and^roid:attr/Textapp: +?android:attr/ diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion11.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion11.xml new file mode 100644 index 000000000..e15b83019 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion11.xml @@ -0,0 +1,15 @@ +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:tools="http://schemas.android.com/tools" + android:layout_width="match_parent" + android:layout_height="match_parent" > + + <TextView + style="?android:attr/Textapp" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_centerHorizontal="true" + android:layout_centerVertical="true" + android:text="@string/hello_world" + tools:context=".MainActivity" /> + +</RelativeLayout> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion12-expected-completion75.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion12-expected-completion75.txt new file mode 100644 index 000000000..5ad38e61c --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion12-expected-completion75.txt @@ -0,0 +1,96 @@ +Code completion in completion12.xml for <include ^/>: +layout : [reference]. * Required. +style : A reference to a custom style [reference] +android:id : Supply an identifier name for this view, to later retrieve it with View.findViewById() or Activity.findViewById(). [reference] +android:tag : Supply a tag for this view containing a String, to be retrieved later with View.getTag() or searched for with View.findViewWithTag() . [string] +android:scrollX : The initial horizontal scroll offset, in pixels. [dimension] +android:scrollY : The initial vertical scroll offset, in pixels. [dimension] +android:background : A drawable to use as the background. [color, reference] +android:padding : Sets the padding, in pixels, of all four edges. [dimension] +android:paddingLeft : Sets the padding, in pixels, of the left edge; see padding. [dimension] +android:paddingTop : Sets the padding, in pixels, of the top edge; see padding. [dimension] +android:paddingRight : Sets the padding, in pixels, of the right edge; see padding. [dimension] +android:paddingBottom : Sets the padding, in pixels, of the bottom edge; see padding. [dimension] +android:paddingStart : Sets the padding, in pixels, of the start edge; see padding. [dimension] +android:paddingEnd : Sets the padding, in pixels, of the end edge; see padding. [dimension] +android:focusable : Boolean that controls whether a view can take focus. [boolean] +android:focusableInTouchMode : Boolean that controls whether a view can take focus while in touch mode. [boolean] +android:visibility : Controls the initial visibility of the view. [enum] +android:fitsSystemWindows : Boolean internal attribute to adjust view layout based on system windows such as the status bar. [boolean] +android:scrollbars : Defines which scrollbars should be displayed on scrolling or not. [flag] +android:scrollbarStyle : Controls the scrollbar style and position. [enum] +android:isScrollContainer : Set this if the view will serve as a scrolling container, meaing that it can be resized to shrink its overall window so that there will be space for an input method. [boolean] +android:fadeScrollbars : Defines whether to fade out scrollbars when they are not in use. [boolean] +android:scrollbarFadeDuration : Defines the delay in milliseconds that a scrollbar takes to fade out. [integer] +android:scrollbarDefaultDelayBeforeFade : Defines the delay in milliseconds that a scrollbar waits before fade out. [integer] +android:scrollbarSize : Sets the width of vertical scrollbars and height of horizontal scrollbars. [dimension] +android:scrollbarThumbHorizontal : Defines the horizontal scrollbar thumb drawable. [reference] +android:scrollbarThumbVertical : Defines the vertical scrollbar thumb drawable. [reference] +android:scrollbarTrackHorizontal : Defines the horizontal scrollbar track drawable. [reference] +android:scrollbarTrackVertical : Defines the vertical scrollbar track drawable. [reference] +android:scrollbarAlwaysDrawHorizontalTrack : Defines whether the horizontal scrollbar track should always be drawn. [boolean] +android:scrollbarAlwaysDrawVerticalTrack : Defines whether the vertical scrollbar track should always be drawn. [boolean] +android:fadingEdge : This attribute is deprecated and will be ignored as of API level 14 (ICE_CREAM_SANDWICH). [flag] +android:requiresFadingEdge : Defines which edges should be faded on scrolling. [flag] +android:fadingEdgeLength : Defines the length of the fading edges. [dimension] +android:nextFocusLeft : Defines the next view to give focus to when the next focus is FOCUS_LEFT. [reference] +android:nextFocusRight : Defines the next view to give focus to when the next focus is FOCUS_RIGHT If the reference refers to a view that does not exist or is part of a hierarchy that is invisible, a java.lang.RuntimeException will result when the reference is accessed. [reference] +android:nextFocusUp : Defines the next view to give focus to when the next focus is FOCUS_UP If the reference refers to a view that does not exist or is part of a hierarchy that is invisible, a java.lang.RuntimeException will result when the reference is accessed. [reference] +android:nextFocusDown : Defines the next view to give focus to when the next focus is FOCUS_DOWN If the reference refers to a view that does not exist or is part of a hierarchy that is invisible, a java.lang.RuntimeException will result when the reference is accessed. [reference] +android:nextFocusForward : Defines the next view to give focus to when the next focus is FOCUS_FORWARD If the reference refers to a view that does not exist or is part of a hierarchy that is invisible, a java.lang.RuntimeException will result when the reference is accessed. [reference] +android:clickable : Defines whether this view reacts to click events. [boolean] +android:longClickable : Defines whether this view reacts to long click events. [boolean] +android:saveEnabled : If unset, no state will be saved for this view when it is being frozen. [boolean] +android:filterTouchesWhenObscured : Specifies whether to filter touches when the view's window is obscured by another visible window. [boolean] +android:drawingCacheQuality : Defines the quality of translucent drawing caches. [enum] +android:keepScreenOn : Controls whether the view's window should keep the screen on while visible. [boolean] +android:duplicateParentState : When this attribute is set to true, the view gets its drawable state (focused, pressed, etc.) from its direct parent rather than from itself. [boolean] +android:minHeight : Defines the minimum height of the view. +android:minWidth : Defines the minimum width of the view. +android:soundEffectsEnabled : Boolean that controls whether a view should have sound effects enabled for events such as clicking and touching. [boolean] +android:hapticFeedbackEnabled : Boolean that controls whether a view should have haptic feedback enabled for events such as long presses. [boolean] +android:contentDescription : Defines text that briefly describes content of the view. [string] +android:onClick : Name of the method in this View's context to invoke when the view is clicked. [string] +android:overScrollMode : Defines over-scrolling behavior. [enum] +android:alpha : alpha property of the view, as a value between 0 (completely transparent) and 1 (completely opaque). [float] +android:translationX : translation in x of the view. [dimension] +android:translationY : translation in y of the view. [dimension] +android:transformPivotX : x location of the pivot point around which the view will rotate and scale. [dimension] +android:transformPivotY : y location of the pivot point around which the view will rotate and scale. [dimension] +android:rotation : rotation of the view, in degrees. [float] +android:rotationX : rotation of the view around the x axis, in degrees. [float] +android:rotationY : rotation of the view around the y axis, in degrees. [float] +android:scaleX : scale of the view in the x direction. [float] +android:scaleY : scale of the view in the y direction. [float] +android:verticalScrollbarPosition : Determines which side the vertical scroll bar should be placed on. [enum] +android:layerType : Specifies the type of layer backing this view. [enum] +android:layoutDirection : Defines the direction of layout drawing. [enum] +android:textDirection : Direction of the text. [integer, enum] +android:textAlignment : Alignment of the text. [integer, enum] +android:importantForAccessibility : Controls how this View is important for accessibility which is if it fires accessibility events and if it is reported to accessibility services that query the screen. [integer, enum] +android:layout_toLeftOf : Positions the right edge of this view to the left of the given anchor view ID. [reference] +android:layout_toRightOf : Positions the left edge of this view to the right of the given anchor view ID. [reference] +android:layout_above : Positions the bottom edge of this view above the given anchor view ID. [reference] +android:layout_below : Positions the top edge of this view below the given anchor view ID. [reference] +android:layout_alignBaseline : Positions the baseline of this view on the baseline of the given anchor view ID. [reference] +android:layout_alignLeft : Makes the left edge of this view match the left edge of the given anchor view ID. [reference] +android:layout_alignTop : Makes the top edge of this view match the top edge of the given anchor view ID. [reference] +android:layout_alignRight : Makes the right edge of this view match the right edge of the given anchor view ID. [reference] +android:layout_alignBottom : Makes the bottom edge of this view match the bottom edge of the given anchor view ID. [reference] +android:layout_alignParentLeft : If true, makes the left edge of this view match the left edge of the parent. [boolean] +android:layout_alignParentTop : If true, makes the top edge of this view match the top edge of the parent. [boolean] +android:layout_alignParentRight : If true, makes the right edge of this view match the right edge of the parent. [boolean] +android:layout_alignParentBottom : If true, makes the bottom edge of this view match the bottom edge of the parent. [boolean] +android:layout_centerInParent : If true, centers this child horizontally and vertically within its parent. [boolean] +android:layout_centerHorizontal : If true, centers this child horizontally within its parent. [boolean] +android:layout_centerVertical : If true, centers this child vertically within its parent. [boolean] +android:layout_alignWithParentIfMissing : If set to true, the parent will be used as the anchor when the anchor cannot be be found for layout_toLeftOf, layout_toRightOf, etc. [boolean] +android:layout_width : Specifies the basic width of the view. [dimension, enum] +android:layout_height : Specifies the basic height of the view. [dimension, enum] +android:layout_margin : Specifies extra space on the left, top, right and bottom sides of this view. [dimension] +android:layout_marginLeft : Specifies extra space on the left side of this view. [dimension] +android:layout_marginTop : Specifies extra space on the top side of this view. [dimension] +android:layout_marginRight : Specifies extra space on the right side of this view. [dimension] +android:layout_marginBottom : Specifies extra space on the bottom side of this view. [dimension] +android:layout_marginStart : Specifies extra space on the start side of this view. [dimension] +android:layout_marginEnd : Specifies extra space on the end side of this view. [dimension] diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion12.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion12.xml new file mode 100644 index 000000000..946a23277 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion12.xml @@ -0,0 +1,7 @@ +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" > + + <include /> + +</RelativeLayout> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion2-expected-applyCompletion13a.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion2-expected-applyCompletion13a.diff new file mode 100644 index 000000000..b36573657 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion2-expected-applyCompletion13a.diff @@ -0,0 +1,4 @@ +Code completion in completion2.xml for gravity="left|bottom|^cen selecting fill_vertical: +@@ -4 +4 +- <TextView android:gravity="left|bottom|^cen"></TextView> ++ <TextView android:gravity="left|bottom|fill_vertical^"></TextView> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion2-expected-applyCompletion13b.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion2-expected-applyCompletion13b.diff new file mode 100644 index 000000000..46268af6d --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion2-expected-applyCompletion13b.diff @@ -0,0 +1,4 @@ +Code completion in completion2.xml for gravity="left|bottom|cen^ selecting center_horizontal: +@@ -4 +4 +- <TextView android:gravity="left|bottom|cen^"></TextView> ++ <TextView android:gravity="left|bottom|center_horizontal^"></TextView> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion2-expected-applyCompletion13c.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion2-expected-applyCompletion13c.diff new file mode 100644 index 000000000..bcac56d16 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion2-expected-applyCompletion13c.diff @@ -0,0 +1,4 @@ +Code completion in completion2.xml for gravity="left|bottom^|cen selecting bottom|fill_horizontal: +@@ -4 +4 +- <TextView android:gravity="left|bottom^|cen"></TextView> ++ <TextView android:gravity="left|bottom|fill_horizontal^"></TextView> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion2-expected-completion13a.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion2-expected-completion13a.txt new file mode 100644 index 000000000..dd28c7365 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion2-expected-completion13a.txt @@ -0,0 +1,15 @@ +Code completion in completion2.xml for gravity="left|bottom|^cen: +top +bottom +left +right +center_vertical +fill_vertical +center_horizontal +fill_horizontal +center +fill +clip_vertical +clip_horizontal +start +end diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion2-expected-completion13b.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion2-expected-completion13b.txt new file mode 100644 index 000000000..8e6d4d865 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion2-expected-completion13b.txt @@ -0,0 +1,4 @@ +Code completion in completion2.xml for gravity="left|bottom|cen^: +center_vertical +center_horizontal +center diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion2-expected-completion13c.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion2-expected-completion13c.txt new file mode 100644 index 000000000..0aebfedea --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion2-expected-completion13c.txt @@ -0,0 +1,14 @@ +Code completion in completion2.xml for gravity="left|bottom^|cen: +bottom +bottom|top +bottom|right +bottom|center_vertical +bottom|fill_vertical +bottom|center_horizontal +bottom|fill_horizontal +bottom|center +bottom|fill +bottom|clip_vertical +bottom|clip_horizontal +bottom|start +bottom|end diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion2.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion2.xml new file mode 100644 index 000000000..0921674cd --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion2.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"> + <!-- Test multiple pipes in the flag value --> + <TextView android:gravity="left|bottom|cen"></TextView> +</LinearLayout> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion3-expected-applyCompletion17.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion3-expected-applyCompletion17.diff new file mode 100644 index 000000000..ef070b28e --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion3-expected-applyCompletion17.diff @@ -0,0 +1,4 @@ +Code completion in completion3.xml for <EditText ^/> selecting android:textColorHighlight: +@@ -3 +3 +- <EditText ^/> ++ <EditText android:textColorHighlight="^"/> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion3-expected-applyCompletion18.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion3-expected-applyCompletion18.diff new file mode 100644 index 000000000..283636b4e --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion3-expected-applyCompletion18.diff @@ -0,0 +1,4 @@ +Code completion in completion3.xml for <Button ^></Button> selecting android:paddingRight: +@@ -4 +4 +- <Button ^></Button> ++ <Button android:paddingRight="^"></Button> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion3.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion3.xml new file mode 100644 index 000000000..afb64b827 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion3.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"> + <EditText /> + <Button ></Button> +</LinearLayout> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion4-expected-completion22.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion4-expected-completion22.txt new file mode 100644 index 000000000..c7170dfcc --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion4-expected-completion22.txt @@ -0,0 +1,2 @@ +Code completion in completion4.xml for <Button^: +Button diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion4.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion4.xml new file mode 100644 index 000000000..0047772f5 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion4.xml @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout + xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent"> + <Button + android:text="@string/app_name" + android:layout_marginLeft="@android:dimen/app_icon_size" + android:id="@+id/button1" + ></Button> +</LinearLayout> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion5-expected-applyCompletion19.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion5-expected-applyCompletion19.diff new file mode 100644 index 000000000..3f7866324 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion5-expected-applyCompletion19.diff @@ -0,0 +1,4 @@ +Code completion in completion5.xml for android:orientation='^' selecting horizontal: +@@ -5 +5 +- android:orientation='^' ++ android:orientation='horizontal'^ diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion5-expected-applyCompletion20.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion5-expected-applyCompletion20.diff new file mode 100644 index 000000000..4933d1320 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion5-expected-applyCompletion20.diff @@ -0,0 +1,4 @@ +Code completion in completion5.xml for android:layout_marginTop='50^dp' selecting 50pt: +@@ -10 +10 +- android:layout_marginTop='50^dp' ++ android:layout_marginTop='50pt'^ diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion5-expected-applyCompletion21.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion5-expected-applyCompletion21.diff new file mode 100644 index 000000000..a4c88d7fc --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion5-expected-applyCompletion21.diff @@ -0,0 +1,4 @@ +Code completion in completion5.xml for android:layout_width='^wrap_content' selecting match_parent: +@@ -11 +11 +- android:layout_width='^wrap_content' ++ android:layout_width='match_parent'^ diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion5-expected-applyCompletion40.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion5-expected-applyCompletion40.diff new file mode 100644 index 000000000..705f865ce --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion5-expected-applyCompletion40.diff @@ -0,0 +1,4 @@ +Code completion in completion5.xml for android:id='@+id/button2'^ selecting android:maxWidth: +@@ -15 +15 +- android:id='@+id/button2'^ ++ android:id='@+id/button2' android:maxWidth="^" diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion5-expected-completion40.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion5-expected-completion40.txt new file mode 100644 index 000000000..a4cf0fa45 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion5-expected-completion40.txt @@ -0,0 +1,156 @@ +Code completion in completion5.xml for android:id='@+id/button2'^: +style : A reference to a custom style [reference] +android:bufferType : Determines the minimum type that getText() will return. [enum] +android:text : Text to display. [string] +android:hint : Hint text to display when the text is empty. [string] +android:textColor : Text color. [color, reference] +android:textColorHighlight : Color of the text selection highlight. [color, reference] +android:textColorHint : Color of the hint text. [color, reference] +android:textAppearance : Base text color, typeface, size, and style. [reference] +android:textSize : Size of the text. [dimension] +android:textScaleX : Sets the horizontal scaling factor for the text. [float] +android:typeface : Typeface (normal, sans, serif, monospace) for the text. [enum] +android:textStyle : Style (bold, italic, bolditalic) for the text. [flag] +android:fontFamily : Font family (named by string) for the text. [string] +android:textColorLink : Text color for links. [color, reference] +android:cursorVisible : Makes the cursor visible (the default) or invisible. [boolean] +android:maxLines : Makes the TextView be at most this many lines tall. [integer] +android:maxHeight : Makes the TextView be at most this many pixels tall. [dimension] +android:lines : Makes the TextView be exactly this many lines tall. [integer] +android:height : Makes the TextView be exactly this many pixels tall. [dimension] +android:minLines : Makes the TextView be at least this many lines tall. [integer] +android:minHeight : Makes the TextView be at least this many pixels tall. [dimension] +android:maxEms : Makes the TextView be at most this many ems wide. [integer] +android:maxWidth : Makes the TextView be at most this many pixels wide. [dimension] +android:ems : Makes the TextView be exactly this many ems wide. [integer] +android:width : Makes the TextView be exactly this many pixels wide. [dimension] +android:minEms : Makes the TextView be at least this many ems wide. [integer] +android:minWidth : Makes the TextView be at least this many pixels wide. [dimension] +android:gravity : Specifies how to align the text by the view's x- and/or y-axis when the text is smaller than the view. [flag] +android:scrollHorizontally : Whether the text is allowed to be wider than the view (and therefore can be scrolled horizontally). [boolean] +android:password : Whether the characters of the field are displayed as password dots instead of themselves. * Deprecated: Use inputType instead. [boolean] +android:singleLine : Constrains the text to a single horizontally scrolling line instead of letting it wrap onto multiple lines, and advances focus instead of inserting a newline when you press the enter key. * Deprecated: This attribute is deprecated. Use "maxLines" instead to change the layo... +android:enabled : Specifies whether the widget is enabled. [boolean] +android:selectAllOnFocus : If the text is selectable, select it all when the view takes focus. [boolean] +android:includeFontPadding : Leave enough room for ascenders and descenders instead of using the font ascent and descent strictly. [boolean] +android:maxLength : Set an input filter to constrain the text length to the specified number. [integer] +android:shadowColor : Place a shadow of the specified color behind the text. [color] +android:shadowDx : Horizontal offset of the shadow. [float] +android:shadowDy : Vertical offset of the shadow. [float] +android:shadowRadius : Radius of the shadow. [float] +android:autoLink : Controls whether links such as urls and email addresses are automatically found and converted to clickable links. [flag] +android:linksClickable : If set to false, keeps the movement method from being set to the link movement method even if autoLink causes links to be found. [boolean] +android:numeric : If set, specifies that this TextView has a numeric input method. * Deprecated: Use inputType instead. [flag] +android:digits : If set, specifies that this TextView has a numeric input method and that these specific characters are the ones that it will accept. [string] +android:phoneNumber : If set, specifies that this TextView has a phone number input method. * Deprecated: Use inputType instead. [boolean] +android:inputMethod : If set, specifies that this TextView should use the specified input method (specified by fully-qualified class name). * Deprecated: Use inputType instead. [string] +android:capitalize : If set, specifies that this TextView has a textual input method and should automatically capitalize what the user types. * Deprecated: Use inputType instead. [enum] +android:autoText : If set, specifies that this TextView has a textual input method and automatically corrects some common spelling errors. * Deprecated: Use inputType instead. [boolean] +android:editable : If set, specifies that this TextView has an input method. * Deprecated: Use inputType instead. [boolean] +android:freezesText : If set, the text view will include its current complete text inside of its frozen icicle in addition to meta-data such as the current cursor position. [boolean] +android:ellipsize : If set, causes words that are longer than the view is wide to be ellipsized instead of broken in the middle. [enum] +android:drawableTop : The drawable to be drawn above the text. [color, reference] +android:drawableBottom : The drawable to be drawn below the text. [color, reference] +android:drawableLeft : The drawable to be drawn to the left of the text. [color, reference] +android:drawableRight : The drawable to be drawn to the right of the text. [color, reference] +android:drawableStart : The drawable to be drawn to the start of the text. [color, reference] +android:drawableEnd : The drawable to be drawn to the end of the text. [color, reference] +android:drawablePadding : The padding between the drawables and the text. [dimension] +android:lineSpacingExtra : Extra spacing between lines of text. [dimension] +android:lineSpacingMultiplier : Extra spacing between lines of text, as a multiplier. [float] +android:marqueeRepeatLimit : The number of times to repeat the marquee animation. [integer, enum] +android:inputType : The type of data being placed in a text field, used to help an input method decide how to let the user enter text. [flag] +android:imeOptions : Additional features you can enable in an IME associated with an editor to improve the integration with your application. [flag] +android:privateImeOptions : An addition content type description to supply to the input method attached to the text view, which is private to the implementation of the input method. [string] +android:imeActionLabel : Supply a value for EditorInfo.actionLabel used when an input method is connected to the text view. [string] +android:imeActionId : Supply a value for EditorInfo.actionId used when an input method is connected to the text view. [integer] +android:editorExtras : Reference to an "input-extras" XML resource containing additional data to supply to an input method, which is private to the implementation of the input method. [reference] +android:textSelectHandleLeft : Reference to a drawable that will be used to display a text selection anchor on the left side of a selection region. [reference] +android:textSelectHandleRight : Reference to a drawable that will be used to display a text selection anchor on the right side of a selection region. [reference] +android:textSelectHandle : Reference to a drawable that will be used to display a text selection anchor for positioning the cursor within text. [reference] +android:textEditPasteWindowLayout : The layout of the view that is displayed on top of the cursor to paste inside a TextEdit field. [reference] +android:textEditNoPasteWindowLayout : Variation of textEditPasteWindowLayout displayed when the clipboard is empty. [reference] +android:textEditSidePasteWindowLayout : Used instead of textEditPasteWindowLayout when the window is moved on the side of the insertion cursor because it would be clipped if it were positioned on top. [reference] +android:textEditSideNoPasteWindowLayout : Variation of textEditSidePasteWindowLayout displayed when the clipboard is empty. [reference] +android:textEditSuggestionItemLayout : Layout of the TextView item that will populate the suggestion popup window. [reference] +android:textCursorDrawable : Reference to a drawable that will be drawn under the insertion cursor. [reference] +android:textIsSelectable : Indicates that the content of a non-editable text can be selected. [boolean] +android:textAllCaps : Present the text in ALL CAPS. [boolean] +android:id : Supply an identifier name for this view, to later retrieve it with View.findViewById() or Activity.findViewById(). [reference] +android:tag : Supply a tag for this view containing a String, to be retrieved later with View.getTag() or searched for with View.findViewWithTag() . [string] +android:scrollX : The initial horizontal scroll offset, in pixels. [dimension] +android:scrollY : The initial vertical scroll offset, in pixels. [dimension] +android:background : A drawable to use as the background. [color, reference] +android:padding : Sets the padding, in pixels, of all four edges. [dimension] +android:paddingLeft : Sets the padding, in pixels, of the left edge; see padding. [dimension] +android:paddingTop : Sets the padding, in pixels, of the top edge; see padding. [dimension] +android:paddingRight : Sets the padding, in pixels, of the right edge; see padding. [dimension] +android:paddingBottom : Sets the padding, in pixels, of the bottom edge; see padding. [dimension] +android:paddingStart : Sets the padding, in pixels, of the start edge; see padding. [dimension] +android:paddingEnd : Sets the padding, in pixels, of the end edge; see padding. [dimension] +android:focusable : Boolean that controls whether a view can take focus. [boolean] +android:focusableInTouchMode : Boolean that controls whether a view can take focus while in touch mode. [boolean] +android:visibility : Controls the initial visibility of the view. [enum] +android:fitsSystemWindows : Boolean internal attribute to adjust view layout based on system windows such as the status bar. [boolean] +android:scrollbars : Defines which scrollbars should be displayed on scrolling or not. [flag] +android:scrollbarStyle : Controls the scrollbar style and position. [enum] +android:isScrollContainer : Set this if the view will serve as a scrolling container, meaing that it can be resized to shrink its overall window so that there will be space for an input method. [boolean] +android:fadeScrollbars : Defines whether to fade out scrollbars when they are not in use. [boolean] +android:scrollbarFadeDuration : Defines the delay in milliseconds that a scrollbar takes to fade out. [integer] +android:scrollbarDefaultDelayBeforeFade : Defines the delay in milliseconds that a scrollbar waits before fade out. [integer] +android:scrollbarSize : Sets the width of vertical scrollbars and height of horizontal scrollbars. [dimension] +android:scrollbarThumbHorizontal : Defines the horizontal scrollbar thumb drawable. [reference] +android:scrollbarThumbVertical : Defines the vertical scrollbar thumb drawable. [reference] +android:scrollbarTrackHorizontal : Defines the horizontal scrollbar track drawable. [reference] +android:scrollbarTrackVertical : Defines the vertical scrollbar track drawable. [reference] +android:scrollbarAlwaysDrawHorizontalTrack : Defines whether the horizontal scrollbar track should always be drawn. [boolean] +android:scrollbarAlwaysDrawVerticalTrack : Defines whether the vertical scrollbar track should always be drawn. [boolean] +android:fadingEdge : This attribute is deprecated and will be ignored as of API level 14 (ICE_CREAM_SANDWICH). [flag] +android:requiresFadingEdge : Defines which edges should be faded on scrolling. [flag] +android:fadingEdgeLength : Defines the length of the fading edges. [dimension] +android:nextFocusLeft : Defines the next view to give focus to when the next focus is FOCUS_LEFT. [reference] +android:nextFocusRight : Defines the next view to give focus to when the next focus is FOCUS_RIGHT If the reference refers to a view that does not exist or is part of a hierarchy that is invisible, a java.lang.RuntimeException will result when the reference is accessed. [reference] +android:nextFocusUp : Defines the next view to give focus to when the next focus is FOCUS_UP If the reference refers to a view that does not exist or is part of a hierarchy that is invisible, a java.lang.RuntimeException will result when the reference is accessed. [reference] +android:nextFocusDown : Defines the next view to give focus to when the next focus is FOCUS_DOWN If the reference refers to a view that does not exist or is part of a hierarchy that is invisible, a java.lang.RuntimeException will result when the reference is accessed. [reference] +android:nextFocusForward : Defines the next view to give focus to when the next focus is FOCUS_FORWARD If the reference refers to a view that does not exist or is part of a hierarchy that is invisible, a java.lang.RuntimeException will result when the reference is accessed. [reference] +android:clickable : Defines whether this view reacts to click events. [boolean] +android:longClickable : Defines whether this view reacts to long click events. [boolean] +android:saveEnabled : If unset, no state will be saved for this view when it is being frozen. [boolean] +android:filterTouchesWhenObscured : Specifies whether to filter touches when the view's window is obscured by another visible window. [boolean] +android:drawingCacheQuality : Defines the quality of translucent drawing caches. [enum] +android:keepScreenOn : Controls whether the view's window should keep the screen on while visible. [boolean] +android:duplicateParentState : When this attribute is set to true, the view gets its drawable state (focused, pressed, etc.) from its direct parent rather than from itself. [boolean] +android:minHeight : Defines the minimum height of the view. +android:minWidth : Defines the minimum width of the view. +android:soundEffectsEnabled : Boolean that controls whether a view should have sound effects enabled for events such as clicking and touching. [boolean] +android:hapticFeedbackEnabled : Boolean that controls whether a view should have haptic feedback enabled for events such as long presses. [boolean] +android:contentDescription : Defines text that briefly describes content of the view. [string] +android:onClick : Name of the method in this View's context to invoke when the view is clicked. [string] +android:overScrollMode : Defines over-scrolling behavior. [enum] +android:alpha : alpha property of the view, as a value between 0 (completely transparent) and 1 (completely opaque). [float] +android:translationX : translation in x of the view. [dimension] +android:translationY : translation in y of the view. [dimension] +android:transformPivotX : x location of the pivot point around which the view will rotate and scale. [dimension] +android:transformPivotY : y location of the pivot point around which the view will rotate and scale. [dimension] +android:rotation : rotation of the view, in degrees. [float] +android:rotationX : rotation of the view around the x axis, in degrees. [float] +android:rotationY : rotation of the view around the y axis, in degrees. [float] +android:scaleX : scale of the view in the x direction. [float] +android:scaleY : scale of the view in the y direction. [float] +android:verticalScrollbarPosition : Determines which side the vertical scroll bar should be placed on. [enum] +android:layerType : Specifies the type of layer backing this view. [enum] +android:layoutDirection : Defines the direction of layout drawing. [enum] +android:textDirection : Direction of the text. [integer, enum] +android:textAlignment : Alignment of the text. [integer, enum] +android:importantForAccessibility : Controls how this View is important for accessibility which is if it fires accessibility events and if it is reported to accessibility services that query the screen. [integer, enum] +android:layout_width : Specifies the basic width of the view. [dimension, enum] +android:layout_height : Specifies the basic height of the view. [dimension, enum] +android:layout_weight : [float] +android:layout_gravity : Standard gravity constant that a child can supply to its parent. [flag] +android:layout_margin : Specifies extra space on the left, top, right and bottom sides of this view. [dimension] +android:layout_marginLeft : Specifies extra space on the left side of this view. [dimension] +android:layout_marginTop : Specifies extra space on the top side of this view. [dimension] +android:layout_marginRight : Specifies extra space on the right side of this view. [dimension] +android:layout_marginBottom : Specifies extra space on the bottom side of this view. [dimension] +android:layout_marginStart : Specifies extra space on the start side of this view. [dimension] +android:layout_marginEnd : Specifies extra space on the end side of this view. [dimension] diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion5.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion5.xml new file mode 100644 index 000000000..757be8b8e --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion5.xml @@ -0,0 +1,23 @@ +<?xml version='1.0' encoding='utf-8'?> +<LinearLayout + xmlns:android='http://schemas.android.com/apk/res/android' + android:layout_width='match_parent' + android:orientation='' + android:layout_height='match_parent'> + <Button + android:text="what's up doc?" + android:id='@+id/button1' + android:layout_marginTop='50dp' + android:layout_width='wrap_content' + android:layout_height='wrap_content'></Button> + <Button + android:text="quote='" + android:id='@+id/button2' + android:layout_width='wrap_content' + android:layout_height='wrap_content'></Button> + <Button + android:text='quote="' + android:id='@+id/button2' + android:layout_width='wrap_content' + android:layout_height='wrap_content'></Button> +</LinearLayout> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion6-expected-applyCompletion22.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion6-expected-applyCompletion22.diff new file mode 100644 index 000000000..92cd2f2ab --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion6-expected-applyCompletion22.diff @@ -0,0 +1,4 @@ +Code completion in completion6.xml for android:orientation="^" selecting horizontal: +@@ -5 +5 +- android:orientation="^" ++ android:orientation="horizontal"^ diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion6.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion6.xml new file mode 100644 index 000000000..55bfa0c93 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion6.xml @@ -0,0 +1,7 @@ +<?xml version='1.0' encoding='utf-8'?> +<LinearLayout + xmlns:android='http://schemas.android.com/apk/res/android' + android:layout_width='match_parent' + android:orientation="" + android:layout_height='match_parent'> +</LinearLayout> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion7-expected-applyCompletion23.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion7-expected-applyCompletion23.diff new file mode 100644 index 000000000..1aaadc267 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion7-expected-applyCompletion23.diff @@ -0,0 +1,4 @@ +Code completion in completion7.xml for android:orientation="^ selecting horizontal: +@@ -5 +5 +- android:orientation="^ ++ android:orientation="horizontal^ diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion7.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion7.xml new file mode 100644 index 000000000..30afbaf4f --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion7.xml @@ -0,0 +1,7 @@ +<?xml version='1.0' encoding='utf-8'?> +<LinearLayout + xmlns:android='http://schemas.android.com/apk/res/android' + android:layout_width='match_parent' + android:orientation=" + android:layout_height='match_parent'> +</LinearLayout> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion8-expected-applyCompletion41.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion8-expected-applyCompletion41.diff new file mode 100644 index 000000000..7678740d1 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion8-expected-applyCompletion41.diff @@ -0,0 +1,4 @@ +Code completion in completion8.xml for android:mar^="50dp" selecting android:layout_marginRight: +@@ -6 +6 +- android:mar^="50dp" ++ android:layout_marginRight^="50dp" diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion8-expected-completion41.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion8-expected-completion41.txt new file mode 100644 index 000000000..0c2e215ec --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion8-expected-completion41.txt @@ -0,0 +1,9 @@ +Code completion in completion8.xml for android:mar^="50dp": +android:layout_margin : Specifies extra space on the left, top, right and bottom sides of this view. [dimension] +android:layout_marginLeft : Specifies extra space on the left side of this view. [dimension] +android:layout_marginTop : Specifies extra space on the top side of this view. [dimension] +android:layout_marginRight : Specifies extra space on the right side of this view. [dimension] +android:layout_marginBottom : Specifies extra space on the bottom side of this view. [dimension] +android:layout_marginStart : Specifies extra space on the start side of this view. [dimension] +android:layout_marginEnd : Specifies extra space on the end side of this view. [dimension] +android:marqueeRepeatLimit : The number of times to repeat the marquee animation. [integer, enum] diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion8-expected-completion42.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion8-expected-completion42.txt new file mode 100644 index 000000000..f5b072093 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion8-expected-completion42.txt @@ -0,0 +1,4 @@ +Code completion in completion8.xml for android:w^i="100": +android:layout_width : Specifies the basic width of the view. [dimension, enum] +android:layout_weight : [float] +android:width : Makes the TextView be exactly this many pixels wide. [dimension] diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion8-expected-completion43.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion8-expected-completion43.txt new file mode 100644 index 000000000..50f13d18b --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion8-expected-completion43.txt @@ -0,0 +1,9 @@ +Code completion in completion8.xml for mar^="60dp": +android:layout_margin : Specifies extra space on the left, top, right and bottom sides of this view. [dimension] +android:layout_marginLeft : Specifies extra space on the left side of this view. [dimension] +android:layout_marginTop : Specifies extra space on the top side of this view. [dimension] +android:layout_marginRight : Specifies extra space on the right side of this view. [dimension] +android:layout_marginBottom : Specifies extra space on the bottom side of this view. [dimension] +android:layout_marginStart : Specifies extra space on the start side of this view. [dimension] +android:layout_marginEnd : Specifies extra space on the end side of this view. [dimension] +android:marqueeRepeatLimit : The number of times to repeat the marquee animation. [integer, enum] diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion8-expected-completion44.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion8-expected-completion44.txt new file mode 100644 index 000000000..357814507 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion8-expected-completion44.txt @@ -0,0 +1,13 @@ +Code completion in completion8.xml for android:layo^ut_width="fill_parent": +android:layout_width : Specifies the basic width of the view. [dimension, enum] +android:layout_height : Specifies the basic height of the view. [dimension, enum] +android:layout_weight : [float] +android:layout_gravity : Standard gravity constant that a child can supply to its parent. [flag] +android:layout_margin : Specifies extra space on the left, top, right and bottom sides of this view. [dimension] +android:layout_marginLeft : Specifies extra space on the left side of this view. [dimension] +android:layout_marginTop : Specifies extra space on the top side of this view. [dimension] +android:layout_marginRight : Specifies extra space on the right side of this view. [dimension] +android:layout_marginBottom : Specifies extra space on the bottom side of this view. [dimension] +android:layout_marginStart : Specifies extra space on the start side of this view. [dimension] +android:layout_marginEnd : Specifies extra space on the end side of this view. [dimension] +android:layoutDirection : Defines the direction of layout drawing. [enum] diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion8.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion8.xml new file mode 100644 index 000000000..3f9d6b537 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion8.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"> + <TextView + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:mar="50dp" + android:wi="100" + mar="60dp" + /> +</LinearLayout> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion9-expected-completion62.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion9-expected-completion62.txt new file mode 100644 index 000000000..9189a827c --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion9-expected-completion62.txt @@ -0,0 +1,2 @@ +Code completion in completion9.xml for android:layout_wi^dth=: +android:layout_width : Specifies the basic width of the view. [dimension, enum] diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion9-expected-completion63.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion9-expected-completion63.txt new file mode 100644 index 000000000..c6ee31dbe --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion9-expected-completion63.txt @@ -0,0 +1 @@ +Code completion in completion9.xml for android:drawable^Top: diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion9-expected-completion64.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion9-expected-completion64.txt new file mode 100644 index 000000000..2085e96da --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion9-expected-completion64.txt @@ -0,0 +1,68 @@ +Code completion in completion9.xml for ^<Button: +<AbsoluteLayout ></AbsoluteLayout> +<AdapterViewFlipper ></AdapterViewFlipper> +<AnalogClock /> +<AutoCompleteTextView /> +<Button /> +<CalendarView /> +<CheckBox /> +<CheckedTextView /> +<Chronometer /> +<DatePicker /> +<DialerFilter ></DialerFilter> +<DigitalClock /> +<EditText /> +<ExpandableListView ></ExpandableListView> +<FrameLayout ></FrameLayout> +<Gallery /> +<GridLayout ></GridLayout> +<GridView ></GridView> +<HorizontalScrollView ></HorizontalScrollView> +<ImageButton /> +<ImageSwitcher ></ImageSwitcher> +<ImageView /> +<LinearLayout ></LinearLayout> +<ListView ></ListView> +<MediaController ></MediaController> +<MultiAutoCompleteTextView /> +<NumberPicker /> +<ProgressBar /> +<QuickContactBadge /> +<RadioButton /> +<RadioGroup ></RadioGroup> +<RatingBar /> +<RelativeLayout ></RelativeLayout> +<ScrollView ></ScrollView> +<SearchView ></SearchView> +<SeekBar /> +<SlidingDrawer ></SlidingDrawer> : SlidingDrawer specific attributes. +<Space /> +<Spinner /> +<StackView ></StackView> +<SurfaceView /> +<Switch /> +<TabHost ></TabHost> +<TabWidget ></TabWidget> +<TableLayout ></TableLayout> +<TableRow ></TableRow> +<TextSwitcher ></TextSwitcher> +<TextView /> +<TextureView /> +<TimePicker /> +<ToggleButton /> +<TwoLineListItem /> +<VideoView /> +<View /> : Attributes that can be used with android.view.View or any of its subclasses. +<ViewAnimator ></ViewAnimator> +<ViewFlipper ></ViewFlipper> +<ViewStub /> : A android.view.ViewStub lets you lazily include other XML layouts inside your application at runtime. +<ViewSwitcher ></ViewSwitcher> +<WebView /> +<ZoomButton /> +<ZoomControls /> +<android.gesture.GestureOverlayView ></android.gesture.GestureOverlayView> : GestureOverlayView specific attributes. +<fragment /> : A Fragment is a piece of an application's user interface or behavior that can be placed in an Activity +<include /> : Lets you statically include XML layouts inside other XML layouts. +<merge ></merge> : A root tag useful for XML layouts inflated using a ViewStub. +<requestFocus /> : Requests focus for the parent element or one of its descendants +<view /> : A view tag whose class attribute names the class to be instantiated diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion9.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion9.xml new file mode 100644 index 000000000..9040d8c1f --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completion9.xml @@ -0,0 +1,10 @@ +<com.google.android.apps.iosched.ui.widget.DashboardLayout + xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="fill_parent" + android:layout_height="fill_parent"> + + <Button android:id="@+id/home_btn_schedule" + style="@style/DashboardButton" + android:text="@string/btn_schedule" + android:drawableTop="@drawable/home_btn_schedule" /> +</com.google.android.apps.iosched.ui.widget.DashboardLayout> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-applyCompletion24a.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-applyCompletion24a.diff new file mode 100644 index 000000000..d3232190c --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-applyCompletion24a.diff @@ -0,0 +1,4 @@ +Code completion in completionvalues1.xml for android:textS^ize selecting android:textSelectHandleLeft: +@@ -4 +4 +- <item name="android:textS^ize">17sp</item> ++ <item name="android:textSelectHandleLeft"^>17sp</item> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-applyCompletion24b.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-applyCompletion24b.diff new file mode 100644 index 000000000..ac71df7eb --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-applyCompletion24b.diff @@ -0,0 +1,4 @@ +Code completion in completionvalues1.xml for 17^sp selecting 17mm: +@@ -4 +4 +- <item name="android:textSize">17^sp</item> ++ <item name="android:textSize">17mm^</item> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-applyCompletion25.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-applyCompletion25.diff new file mode 100644 index 000000000..df6fceb9e --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-applyCompletion25.diff @@ -0,0 +1,4 @@ +Code completion in completionvalues1.xml for textColor">^@color/title_color</item> selecting @android:: +@@ -5 +5 +- <item name="android:textColor">^@color/title_color</item> ++ <item name="android:textColor">@android:^</item> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-applyCompletion26.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-applyCompletion26.diff new file mode 100644 index 000000000..36fce8b9e --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-applyCompletion26.diff @@ -0,0 +1,4 @@ +Code completion in completionvalues1.xml for <item name="android:shadowColor">@an^</item> selecting @android:: +@@ -6 +6 +- <item name="android:shadowColor">@an^</item> ++ <item name="android:shadowColor">@android:^</item> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-applyCompletion27.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-applyCompletion27.diff new file mode 100644 index 000000000..6315fc4fd --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-applyCompletion27.diff @@ -0,0 +1,4 @@ +Code completion in completionvalues1.xml for <item name="android:gravity">^ </item> selecting center_vertical: +@@ -7 +7 +- <item name="android:gravity">^ </item> ++ <item name="android:gravity">center_vertical^</item> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-applyCompletion28.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-applyCompletion28.diff new file mode 100644 index 000000000..1db9773a1 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-applyCompletion28.diff @@ -0,0 +1,4 @@ +Code completion in completionvalues1.xml for <item name="android:gravity"> ^</item> selecting left: +@@ -7 +7 +- <item name="android:gravity"> ^</item> ++ <item name="android:gravity"> left^</item> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-applyCompletion29.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-applyCompletion29.diff new file mode 100644 index 000000000..63076464d --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-applyCompletion29.diff @@ -0,0 +1,4 @@ +Code completion in completionvalues1.xml for <item name="gr^"> selecting android:gravity: +@@ -8 +8 +- <item name="gr^">@color/title_color</item> ++ <item name="android:gravity"^>@color/title_color</item> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-applyCompletion30.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-applyCompletion30.diff new file mode 100644 index 000000000..c8a119fd9 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-applyCompletion30.diff @@ -0,0 +1,4 @@ +Code completion in completionvalues1.xml for <item name="an^"> selecting android:animateOnClick: +@@ -9 +9 +- <item name="an^">@color/title_color</item> ++ <item name="android:animateOnClick"^>@color/title_color</item> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-applyCompletion31.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-applyCompletion31.diff new file mode 100644 index 000000000..9b3743807 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-applyCompletion31.diff @@ -0,0 +1,4 @@ +Code completion in completionvalues1.xml for <item ^></item> selecting name: +@@ -10 +10 +- <item ^></item> ++ <item name="^"></item> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-applyCompletion32.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-applyCompletion32.diff new file mode 100644 index 000000000..b34a8ec5c --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-applyCompletion32.diff @@ -0,0 +1,4 @@ +Code completion in completionvalues1.xml for <item name="^"></item> selecting android:background: +@@ -11 +11 +- <item name="^"></item> ++ <item name="android:background"^></item> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-applyCompletion33.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-applyCompletion33.diff new file mode 100644 index 000000000..b78adee5b --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-applyCompletion33.diff @@ -0,0 +1,4 @@ +Code completion in completionvalues1.xml for <item name="android:allowSingleTap">^</item> selecting true: +@@ -12 +12 +- <item name="android:allowSingleTap">^</item> ++ <item name="android:allowSingleTap">true^</item> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-applyCompletion34.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-applyCompletion34.diff new file mode 100644 index 000000000..5af6c92d5 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-applyCompletion34.diff @@ -0,0 +1,4 @@ +Code completion in completionvalues1.xml for <item name="android:alwaysDrawnWithCache">^ false </item> selecting true: +@@ -13 +13 +- <item name="android:alwaysDrawnWithCache">^ false </item> ++ <item name="android:alwaysDrawnWithCache">true^</item> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-applyCompletion35.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-applyCompletion35.diff new file mode 100644 index 000000000..f48f10143 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-applyCompletion35.diff @@ -0,0 +1,4 @@ +Code completion in completionvalues1.xml for <item name="android:alwaysDrawnWithCache"> ^false </item> selecting true: +@@ -13 +13 +- <item name="android:alwaysDrawnWithCache"> ^false </item> ++ <item name="android:alwaysDrawnWithCache"> true^</item> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-applyCompletion36.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-applyCompletion36.diff new file mode 100644 index 000000000..8c246a8ff --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-applyCompletion36.diff @@ -0,0 +1,4 @@ +Code completion in completionvalues1.xml for <item name="android:alwaysDrawnWithCache"> f^alse </item> selecting false: +@@ -13 +13 +- <item name="android:alwaysDrawnWithCache"> f^alse </item> ++ <item name="android:alwaysDrawnWithCache"> false^</item> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-applyCompletion37.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-applyCompletion37.diff new file mode 100644 index 000000000..082f2b25c --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-applyCompletion37.diff @@ -0,0 +1,4 @@ +Code completion in completionvalues1.xml for <item name="android:orientation">h^</item> selecting horizontal: +@@ -14 +14 +- <item name="android:orientation">h^</item> ++ <item name="android:orientation">horizontal^</item> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-applyCompletion38.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-applyCompletion38.diff new file mode 100644 index 000000000..47580e1d8 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-applyCompletion38.diff @@ -0,0 +1,4 @@ +Code completion in completionvalues1.xml for c^ selecting center: +@@ -16 +16 +- c^ ++ center^ diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-applyCompletion44.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-applyCompletion44.diff new file mode 100644 index 000000000..57fe472e5 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-applyCompletion44.diff @@ -0,0 +1,4 @@ +Code completion in completionvalues1.xml for [^false] selecting true: +@@ -13 +13 +- <item name="android:alwaysDrawnWithCache"> ^false </item> ++ <item name="android:alwaysDrawnWithCache"> true^</item> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-completion23.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-completion23.txt new file mode 100644 index 000000000..a2f64dc72 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-completion23.txt @@ -0,0 +1,7 @@ +Code completion in completionvalues1.xml for android:textS^ize: +android:textScaleX : Sets the horizontal scaling factor for the text. [float] +android:textSelectHandle : Reference to a drawable that will be used to display a text selection anchor for positioning the cursor within text. [reference] +android:textSelectHandleLeft : Reference to a drawable that will be used to display a text selection anchor on the left side of a selection region. [reference] +android:textSelectHandleRight : Reference to a drawable that will be used to display a text selection anchor on the right side of a selection region. [reference] +android:textSize : Size of the text. [dimension] +android:textStyle : Style (bold, italic, bolditalic) for the text. [flag] diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-completion24.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-completion24.txt new file mode 100644 index 000000000..c1de9ec99 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-completion24.txt @@ -0,0 +1,7 @@ +Code completion in completionvalues1.xml for 17^sp: +17dp : <b>Density-independent Pixels</b> - an abstract unit that is based on the physical density of the screen. +17sp : <b>Scale-independent Pixels</b> - this is like the dp unit, but it is also scaled by the user's font size preference. +17pt : <b>Points</b> - 1/72 of an inch based on the physical size of the screen. +17mm : <b>Millimeters</b> - based on the physical size of the screen. +17in : <b>Inches</b> - based on the physical size of the screen. +17px : <b>Pixels</b> - corresponds to actual pixels on the screen. Not recommended. diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-completion25.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-completion25.txt new file mode 100644 index 000000000..b57246dd0 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-completion25.txt @@ -0,0 +1,8 @@ +Code completion in completionvalues1.xml for textColor">^@color/title_color</item>: +@android: +@+id/ +@drawable/ +@id/ +@layout/ +@string/ +@style/ diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-completion26.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-completion26.txt new file mode 100644 index 000000000..b1c541c38 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-completion26.txt @@ -0,0 +1,2 @@ +Code completion in completionvalues1.xml for <item name="android:shadowColor">@an^</item>: +@android: diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-completion27.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-completion27.txt new file mode 100644 index 000000000..22b636ddf --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-completion27.txt @@ -0,0 +1,15 @@ +Code completion in completionvalues1.xml for <item name="android:gravity">^ </item>: +top +bottom +left +right +center_vertical +fill_vertical +center_horizontal +fill_horizontal +center +fill +clip_vertical +clip_horizontal +start +end diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-completion28.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-completion28.txt new file mode 100644 index 000000000..2a850294d --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-completion28.txt @@ -0,0 +1,15 @@ +Code completion in completionvalues1.xml for <item name="android:gravity"> ^</item>: +top +bottom +left +right +center_vertical +fill_vertical +center_horizontal +fill_horizontal +center +fill +clip_vertical +clip_horizontal +start +end diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-completion29.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-completion29.txt new file mode 100644 index 000000000..c082ce44b --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-completion29.txt @@ -0,0 +1,3 @@ +Code completion in completionvalues1.xml for <item name="gr^">: +android:gravity : Specifies how to place the content of an object, both on the x- and y-axis, within the object itself. [flag] +android:groupIndicator : Indicator shown beside the group View. [reference] diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-completion30.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-completion30.txt new file mode 100644 index 000000000..efee2bcf5 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-completion30.txt @@ -0,0 +1,8 @@ +Code completion in completionvalues1.xml for <item name="an^">: +android: +android:animateFirstView : Defines whether to animate the current View when the ViewAnimation is first displayed. [boolean] +android:animateLayoutChanges : Defines whether changes in layout (caused by adding and removing items) should cause a LayoutTransition to run. [boolean] +android:animateOnClick : Indicates whether the drawer should be opened/closed with an animation when the user clicks the handle. [boolean] +android:animationCache : Defines whether layout animations should create a drawing cache for their children. [boolean] +android:animationDuration : Sets how long a transition animation should run (in milliseconds) when layout has changed. [integer] +android:animationResolution : Timeout between frames of animation in milliseconds * Deprecated: Not used by the framework. [integer] diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-completion31.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-completion31.txt new file mode 100644 index 000000000..90441643c --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-completion31.txt @@ -0,0 +1,2 @@ +Code completion in completionvalues1.xml for <item ^></item>: +name : The mandatory name used in referring to this item. diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-completion32.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-completion32.txt new file mode 100644 index 000000000..57684d7ce --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-completion32.txt @@ -0,0 +1,317 @@ +Code completion in completionvalues1.xml for <item name="^"></item>: +android: +android:addStatesFromChildren : Sets whether this ViewGroup's drawable states also include its children's drawable states. [boolean] +android:adjustViewBounds : Set this to true if you want the ImageView to adjust its bounds to preserve the aspect ratio of its drawable. [boolean] +android:alignmentMode : When set to alignMargins, causes alignment to take place between the outer boundary of a view, as defined by its margins. [enum] +android:allowSingleTap : Indicates whether the drawer can be opened/closed by a single tap on the handle. [boolean] +android:alpha : alpha property of the view, as a value between 0 (completely transparent) and 1 (completely opaque). [float] +android:alwaysDrawnWithCache : Defines whether the ViewGroup should always draw its children using their drawing cache or not. [boolean] +android:animateFirstView : Defines whether to animate the current View when the ViewAnimation is first displayed. [boolean] +android:animateLayoutChanges : Defines whether changes in layout (caused by adding and removing items) should cause a LayoutTransition to run. [boolean] +android:animateOnClick : Indicates whether the drawer should be opened/closed with an animation when the user clicks the handle. [boolean] +android:animationCache : Defines whether layout animations should create a drawing cache for their children. [boolean] +android:animationDuration : Sets how long a transition animation should run (in milliseconds) when layout has changed. [integer] +android:animationResolution : Timeout between frames of animation in milliseconds * Deprecated: Not used by the framework. [integer] +android:autoLink : Controls whether links such as urls and email addresses are automatically found and converted to clickable links. [flag] +android:autoStart : When true, automatically start animating [boolean] +android:autoText : If set, specifies that this TextView has a textual input method and automatically corrects some common spelling errors. * Deprecated: Use inputType instead. [boolean] +android:background : A drawable to use as the background. [color, reference] +android:baseline : The offset of the baseline within this view. [dimension] +android:baselineAlignBottom : If true, the image view will be baseline aligned with based on its bottom edge. [boolean] +android:baselineAligned : When set to false, prevents the layout from aligning its children's baselines. [boolean] +android:baselineAlignedChildIndex : When a linear layout is part of another layout that is baseline aligned, it can specify which of its children to baseline align to (that is, which child TextView). [integer] +android:bottomOffset : Extra offset for the handle at the bottom of the SlidingDrawer. [dimension] +android:bufferType : Determines the minimum type that getText() will return. [enum] +android:button : Drawable used for the button graphic (e.g. checkbox, radio button, etc). [reference] +android:cacheColorHint : Indicates that this list will always be drawn on top of solid, single-color opaque background. [color] +android:calendarViewShown : Whether the calendar view is shown. [boolean] +android:capitalize : If set, specifies that this TextView has a textual input method and should automatically capitalize what the user types. * Deprecated: Use inputType instead. [enum] +android:checkMark : Drawable used for the check mark graphic. [reference] +android:checked : Indicates the initial checked state of this button. [boolean] +android:checkedButton : The id of the child radio button that should be checked by default within this radio group. [integer] +android:childDivider : Drawable or color that is used as a divider for children. [color, reference] +android:childIndicator : Indicator shown beside the child View. [reference] +android:childIndicatorLeft : The left bound for a child's indicator. [dimension] +android:childIndicatorRight : The right bound for a child's indicator. [dimension] +android:choiceMode : Defines the choice behavior for the view. [enum] +class : Supply the name of the view class to instantiate +android:clickColor : Color of the outline of click feedback. [color] +android:clickable : Defines whether this view reacts to click events. [boolean] +android:clipChildren : Defines whether a child is limited to draw inside of its bounds or not. [boolean] +android:clipToPadding : Defines whether the ViewGroup will clip its drawing surface so as to exclude the padding area. [boolean] +android:collapseColumns : The zero-based index of the columns to collapse. [string] +android:columnCount : The maxmimum number of columns to create when automatically positioning children. [integer] +android:columnOrderPreserved : When set to true, forces column boundaries to appear in the same order as column indices. [boolean] +android:columnWidth : Specifies the fixed width for each column. [dimension] +android:completionHint : Defines the hint displayed in the drop down menu. [string] +android:completionHintView : Defines the hint view displayed in the drop down menu. [reference] +android:completionThreshold : Defines the number of characters that the user must type before completion suggestions are displayed in a drop down menu. [integer] +android:content : Identifier for the child that represents the drawer's content. [reference] +android:contentDescription : Defines text that briefly describes content of the view. [string] +android:cropToPadding : If true, the image will be cropped to fit within its padding. [boolean] +android:cursorVisible : Makes the cursor visible (the default) or invisible. [boolean] +android:dateTextAppearance : The text appearance for the calendar dates. [reference] +android:descendantFocusability : Defines the relationship between the ViewGroup and its descendants when looking for a View to take focus. [enum] +android:dial : [reference] +android:digits : If set, specifies that this TextView has a numeric input method and that these specific characters are the ones that it will accept. [string] +android:disableChildrenWhenDisabled : Whether this spinner should mark child views as enabled/disabled when the spinner itself is enabled/disabled. [boolean] +android:disabledAlpha : The alpha to apply to the indicator when disabled. [float] +android:divider : Drawable to use as a vertical divider between buttons. +android:dividerHeight : Height of the divider. [dimension] +android:dividerPadding : Size of padding on either end of a divider. [dimension] +android:drawSelectorOnTop : When set to true, the selector will be drawn over the selected item. [boolean] +android:drawableBottom : The drawable to be drawn below the text. [color, reference] +android:drawableEnd : The drawable to be drawn to the end of the text. [color, reference] +android:drawableLeft : The drawable to be drawn to the left of the text. [color, reference] +android:drawablePadding : The padding between the drawables and the text. [dimension] +android:drawableRight : The drawable to be drawn to the right of the text. [color, reference] +android:drawableStart : The drawable to be drawn to the start of the text. [color, reference] +android:drawableTop : The drawable to be drawn above the text. [color, reference] +android:drawingCacheQuality : Defines the quality of translucent drawing caches. [enum] +android:dropDownAnchor : View to anchor the auto-complete dropdown to. [reference] +android:dropDownHeight : Specifies the basic height of the dropdown. [dimension, enum] +android:dropDownHorizontalOffset : Horizontal offset from the spinner widget for positioning the dropdown in spinnerMode="dropdown". [dimension] +android:dropDownSelector : List selector to use for spinnerMode="dropdown" display. [color, reference] +android:dropDownVerticalOffset : Vertical offset from the spinner widget for positioning the dropdown in spinnerMode="dropdown". [dimension] +android:dropDownWidth : Width of the dropdown in spinnerMode="dropdown". [dimension, enum] +android:duplicateParentState : When this attribute is set to true, the view gets its drawable state (focused, pressed, etc.) from its direct parent rather than from itself. [boolean] +android:editable : If set, specifies that this TextView has an input method. * Deprecated: Use inputType instead. [boolean] +android:editorExtras : Reference to an "input-extras" XML resource containing additional data to supply to an input method, which is private to the implementation of the input method. [reference] +android:ellipsize : If set, causes words that are longer than the view is wide to be ellipsized instead of broken in the middle. [enum] +android:ems : Makes the TextView be exactly this many ems wide. [integer] +android:enabled : Specifies whether the widget is enabled. [boolean] +android:endYear : The last year (inclusive), for example "2010". * Deprecated: Use maxDate instead. [integer] +android:entries : Reference to an array resource that will populate the Spinner. [reference] +android:eventsInterceptionEnabled : Defines whether the overlay should intercept the motion events when a gesture is recognized. [boolean] +android:fadeDuration : Duration, in milliseconds, of the fade out effect after the user is done drawing a gesture. [integer] +android:fadeEnabled : Defines whether the gesture will automatically fade out after being recognized. [boolean] +android:fadeOffset : Time, in milliseconds, to wait before the gesture fades out after the user is done drawing it. [integer] +android:fadeScrollbars : Defines whether to fade out scrollbars when they are not in use. [boolean] +android:fadingEdge : This attribute is deprecated and will be ignored as of API level 14 (ICE_CREAM_SANDWICH). [flag] +android:fadingEdgeLength : Defines the length of the fading edges. [dimension] +android:fastScrollAlwaysVisible : When set to true, the list will always show the fast scroll interface. [boolean] +android:fastScrollEnabled : Enables the fast scroll thumb that can be dragged to quickly scroll through the list. [boolean] +android:fillViewport : Defines whether the scrollview should stretch its content to fill the viewport. [boolean] +android:filterTouchesWhenObscured : Specifies whether to filter touches when the view's window is obscured by another visible window. [boolean] +android:firstDayOfWeek : The first day of week according to java.util.Calendar. [integer] +android:fitsSystemWindows : Boolean internal attribute to adjust view layout based on system windows such as the status bar. [boolean] +android:flipInterval : [integer] +android:focusable : Boolean that controls whether a view can take focus. [boolean] +android:focusableInTouchMode : Boolean that controls whether a view can take focus while in touch mode. [boolean] +android:focusedMonthDateColor : The color for the dates of the focused month. [color, reference] +android:fontFamily : Font family (named by string) for the text. [string] +android:footerDividersEnabled : When set to false, the ListView will not draw the divider before each footer view. [boolean] +android:foreground : Defines the drawable to draw over the content. [color, reference] +android:foregroundGravity : Defines the gravity to apply to the foreground drawable. [flag] +android:foregroundInsidePadding : Defines whether the foreground drawable should be drawn inside the padding. [boolean] +android:format : Format string: if specified, the Chronometer will display this string, with the first "%s" replaced by the current timer value in "MM:SS" or "H:MM:SS" form. [string] +android:freezesText : If set, the text view will include its current complete text inside of its frozen icicle in addition to meta-data such as the current cursor position. [boolean] +android:gestureColor : Color used to draw a gesture. [color] +android:gestureStrokeAngleThreshold : Minimum curve angle a stroke must contain before it is recognized as a gesture. [float] +android:gestureStrokeLengthThreshold : Minimum length of a stroke before it is recognized as a gesture. [float] +android:gestureStrokeSquarenessThreshold : Squareness threshold of a stroke before it is recognized as a gesture. [float] +android:gestureStrokeType : Defines the type of strokes that define a gesture. [enum] +android:gestureStrokeWidth : Width of the stroke used to draw the gesture. [float] +android:gravity : Specifies how to place the content of an object, both on the x- and y-axis, within the object itself. [flag] +android:groupIndicator : Indicator shown beside the group View. [reference] +android:hand_hour : [reference] +android:hand_minute : [reference] +android:handle : Identifier for the child that represents the drawer's handle. [reference] +android:hapticFeedbackEnabled : Boolean that controls whether a view should have haptic feedback enabled for events such as long presses. [boolean] +android:headerDividersEnabled : When set to false, the ListView will not draw the divider after each header view. [boolean] +android:height : Makes the TextView be exactly this many pixels tall. [dimension] +android:hint : Hint text to display when the text is empty. [string] +android:horizontalSpacing : Defines the default horizontal spacing between columns. [dimension] +android:iconifiedByDefault : The default state of the SearchView. [boolean] +android:id : Supply an identifier name for the top-level view, to later retrieve it with View.findViewById() or Activity.findViewById(). [reference] +android:ignoreGravity : Indicates what view should not be affected by gravity. [reference] +android:imeActionId : Supply a value for EditorInfo.actionId used when an input method is connected to the text view. [integer] +android:imeActionLabel : Supply a value for EditorInfo.actionLabel used when an input method is connected to the text view. [string] +android:imeOptions : Additional features you can enable in an IME associated with an editor to improve the integration with your application. [flag] +android:importantForAccessibility : Controls how this View is important for accessibility which is if it fires accessibility events and if it is reported to accessibility services that query the screen. [integer, enum] +android:inAnimation : Identifier for the animation to use when a view is shown. [reference] +android:includeFontPadding : Leave enough room for ascenders and descenders instead of using the font ascent and descent strictly. [boolean] +android:indeterminate : Allows to enable the indeterminate mode. [boolean] +android:indeterminateBehavior : Defines how the indeterminate mode should behave when the progress reaches max. [enum] +android:indeterminateDrawable : Drawable used for the indeterminate mode. [reference] +android:indeterminateDuration : Duration of the indeterminate animation. [integer] +android:indeterminateOnly : Restricts to ONLY indeterminate mode (state-keeping progress mode will not work). [boolean] +android:indicatorLeft : The left bound for an item's indicator. [dimension] +android:indicatorRight : The right bound for an item's indicator. [dimension] +android:inflatedId : Overrides the id of the inflated View with this value. [reference] +android:inputMethod : If set, specifies that this TextView should use the specified input method (specified by fully-qualified class name). * Deprecated: Use inputType instead. [string] +android:inputType : The type of data being placed in a text field, used to help an input method decide how to let the user enter text. [flag] +android:interpolator : [reference] +android:isIndicator : Whether this rating bar is an indicator (and non-changeable by the user). [boolean] +android:isScrollContainer : Set this if the view will serve as a scrolling container, meaing that it can be resized to shrink its overall window so that there will be space for an input method. [boolean] +android:keepScreenOn : Controls whether the view's window should keep the screen on while visible. [boolean] +android:layerType : Specifies the type of layer backing this view. [enum] +layout : [reference]. * Required. +android:layoutAnimation : Defines the layout animation to use the first time the ViewGroup is laid out. [reference] +android:layoutDirection : Defines the direction of layout drawing. [enum] +android:lineSpacingExtra : Extra spacing between lines of text. [dimension] +android:lineSpacingMultiplier : Extra spacing between lines of text, as a multiplier. [float] +android:lines : Makes the TextView be exactly this many lines tall. [integer] +android:linksClickable : If set to false, keeps the movement method from being set to the link movement method even if autoLink causes links to be found. [boolean] +android:listSelector : Drawable used to indicate the currently selected item in the list. [color, reference] +android:longClickable : Defines whether this view reacts to long click events. [boolean] +android:loopViews : Defines whether the animator loops to the first view once it has reached the end of the list. [boolean] +android:marqueeRepeatLimit : The number of times to repeat the marquee animation. [integer, enum] +android:max : Defines the maximum value the progress can take. [integer] +android:maxDate : The minimal date shown by this calendar view in mm/dd/yyyy format. [string] +android:maxEms : Makes the TextView be at most this many ems wide. [integer] +android:maxHeight : An optional argument to supply a maximum height for this view. [dimension] +android:maxLength : Set an input filter to constrain the text length to the specified number. [integer] +android:maxLines : Makes the TextView be at most this many lines tall. [integer] +android:maxWidth : An optional argument to supply a maximum width for this view. [dimension] +android:measureAllChildren : Determines whether to measure all children or just those in the VISIBLE or INVISIBLE state when measuring. [boolean] +android:measureWithLargestChild : When set to true, all children with a weight will be considered having the minimum size of the largest child. [boolean] +android:minDate : The minimal date shown by this calendar view in mm/dd/yyyy format. [string] +android:minEms : Makes the TextView be at least this many ems wide. [integer] +android:minHeight : Defines the minimum height of the view. +android:minLines : Makes the TextView be at least this many lines tall. [integer] +android:minWidth : Defines the minimum width of the view. +android:mode : [enum] +android:name : Supply the name of the fragment class to instantiate. +android:nextFocusDown : Defines the next view to give focus to when the next focus is FOCUS_DOWN If the reference refers to a view that does not exist or is part of a hierarchy that is invisible, a java.lang.RuntimeException will result when the reference is accessed. [reference] +android:nextFocusForward : Defines the next view to give focus to when the next focus is FOCUS_FORWARD If the reference refers to a view that does not exist or is part of a hierarchy that is invisible, a java.lang.RuntimeException will result when the reference is accessed. [reference] +android:nextFocusLeft : Defines the next view to give focus to when the next focus is FOCUS_LEFT. [reference] +android:nextFocusRight : Defines the next view to give focus to when the next focus is FOCUS_RIGHT If the reference refers to a view that does not exist or is part of a hierarchy that is invisible, a java.lang.RuntimeException will result when the reference is accessed. [reference] +android:nextFocusUp : Defines the next view to give focus to when the next focus is FOCUS_UP If the reference refers to a view that does not exist or is part of a hierarchy that is invisible, a java.lang.RuntimeException will result when the reference is accessed. [reference] +android:numColumns : Defines how many columns to show. [integer, enum] +android:numStars : The number of stars (or rating items) to show. [integer] +android:numeric : If set, specifies that this TextView has a numeric input method. * Deprecated: Use inputType instead. [flag] +android:onClick : Name of the method in this View's context to invoke when the view is clicked. [string] +android:orientation : Should the layout be a column or a row? Use "horizontal" for a row, "vertical" for a column. [enum] +android:outAnimation : Identifier for the animation to use when a view is hidden. [reference] +android:overScrollFooter : Drawable to draw below list content. [color, reference] +android:overScrollHeader : Drawable to draw above list content. [color, reference] +android:overScrollMode : Defines over-scrolling behavior. [enum] +android:padding : Sets the padding, in pixels, of all four edges. [dimension] +android:paddingBottom : Sets the padding, in pixels, of the bottom edge; see padding. [dimension] +android:paddingEnd : Sets the padding, in pixels, of the end edge; see padding. [dimension] +android:paddingLeft : Sets the padding, in pixels, of the left edge; see padding. [dimension] +android:paddingRight : Sets the padding, in pixels, of the right edge; see padding. [dimension] +android:paddingStart : Sets the padding, in pixels, of the start edge; see padding. [dimension] +android:paddingTop : Sets the padding, in pixels, of the top edge; see padding. [dimension] +android:password : Whether the characters of the field are displayed as password dots instead of themselves. * Deprecated: Use inputType instead. [boolean] +android:persistentDrawingCache : Defines the persistence of the drawing cache. [flag] +android:phoneNumber : If set, specifies that this TextView has a phone number input method. * Deprecated: Use inputType instead. [boolean] +android:popupBackground : Background drawable to use for the dropdown in spinnerMode="dropdown". [color, reference] +android:popupPromptView : Reference to a layout to use for displaying a prompt in the dropdown for spinnerMode="dropdown". [reference] +android:privateImeOptions : An addition content type description to supply to the input method attached to the text view, which is private to the implementation of the input method. [string] +android:progress : Defines the default progress value, between 0 and max. [integer] +android:progressDrawable : Drawable used for the progress mode. [reference] +android:prompt : The prompt to display when the spinner's dialog is shown. [reference] +android:queryHint : An optional query hint string to be displayed in the empty query field. [string] +android:quickContactWindowSize : [enum] +android:rating : The rating to set by default. [float] +android:requiresFadingEdge : Defines which edges should be faded on scrolling. [flag] +android:resOutColor : Color of the res-out outline. [color] +android:rotation : rotation of the view, in degrees. [float] +android:rotationX : rotation of the view around the x axis, in degrees. [float] +android:rotationY : rotation of the view around the y axis, in degrees. [float] +android:rowCount : The maxmimum number of rows to create when automatically positioning children. [integer] +android:rowOrderPreserved : When set to true, forces row boundaries to appear in the same order as row indices. [boolean] +android:saveEnabled : If unset, no state will be saved for this view when it is being frozen. [boolean] +android:scaleType : Controls how the image should be resized or moved to match the size of this ImageView. [enum] +android:scaleX : scale of the view in the x direction. [float] +android:scaleY : scale of the view in the y direction. [float] +android:scrollHorizontally : Whether the text is allowed to be wider than the view (and therefore can be scrolled horizontally). [boolean] +android:scrollX : The initial horizontal scroll offset, in pixels. [dimension] +android:scrollY : The initial vertical scroll offset, in pixels. [dimension] +android:scrollbarAlwaysDrawHorizontalTrack : Defines whether the horizontal scrollbar track should always be drawn. [boolean] +android:scrollbarAlwaysDrawVerticalTrack : Defines whether the vertical scrollbar track should always be drawn. [boolean] +android:scrollbarDefaultDelayBeforeFade : Defines the delay in milliseconds that a scrollbar waits before fade out. [integer] +android:scrollbarFadeDuration : Defines the delay in milliseconds that a scrollbar takes to fade out. [integer] +android:scrollbarSize : Sets the width of vertical scrollbars and height of horizontal scrollbars. [dimension] +android:scrollbarStyle : Controls the scrollbar style and position. [enum] +android:scrollbarThumbHorizontal : Defines the horizontal scrollbar thumb drawable. [reference] +android:scrollbarThumbVertical : Defines the vertical scrollbar thumb drawable. [reference] +android:scrollbarTrackHorizontal : Defines the horizontal scrollbar track drawable. [reference] +android:scrollbarTrackVertical : Defines the vertical scrollbar track drawable. [reference] +android:scrollbars : Defines which scrollbars should be displayed on scrolling or not. [flag] +android:scrollingCache : When set to true, the list uses a drawing cache during scrolling. [boolean] +android:secondaryProgress : Defines the secondary progress value, between 0 and max. [integer] +android:selectAllOnFocus : If the text is selectable, select it all when the view takes focus. [boolean] +android:selectedDateVerticalBar : Drawable for the vertical bar shown at the beginning and at the end of the selected date. [reference] +android:selectedWeekBackgroundColor : The background color for the selected week. [color, reference] +android:shadowColor : Place a shadow of the specified color behind the text. [color] +android:shadowDx : Horizontal offset of the shadow. [float] +android:shadowDy : Vertical offset of the shadow. [float] +android:shadowRadius : Radius of the shadow. [float] +android:showDividers : Setting for which dividers to show. [flag] +android:showWeekNumber : Whether do show week numbers. [boolean] +android:shownWeekCount : The number of weeks to be shown. [integer] +android:shrinkColumns : The zero-based index of the columns to shrink. [string] +android:singleLine : Constrains the text to a single horizontally scrolling line instead of letting it wrap onto multiple lines, and advances focus instead of inserting a newline when you press the enter key. * Deprecated: This attribute is deprecated. Use "maxLines" instead to change the layo... +android:smoothScrollbar : When set to true, the list will use a more refined calculation method based on the pixels height of the items visible on screen. [boolean] +android:soundEffectsEnabled : Boolean that controls whether a view should have sound effects enabled for events such as clicking and touching. [boolean] +android:spacing : [dimension] +android:spinnerMode : Display mode for spinner options. [enum] +android:spinnersShown : Whether the spinners are shown. [boolean] +android:splitMotionEvents : Sets whether this ViewGroup should split MotionEvents to separate child views during touch event dispatch. [boolean] +android:src : Sets a drawable as the content of this ImageView. [color, reference] +android:stackFromBottom : Used by ListView and GridView to stack their content from the bottom. [boolean] +android:startYear : The first year (inclusive), for example "1940". * Deprecated: Use minDate instead. [integer] +android:stepSize : The step size of the rating. [float] +android:stretchColumns : The zero-based index of the columns to stretch. [string] +android:stretchMode : Defines how columns should stretch to fill the available empty space, if any. [enum] +style : A reference to a custom style [reference] +android:switchMinWidth : Minimum width for the switch component [dimension] +android:switchPadding : Minimum space between the switch and caption text [dimension] +android:switchTextAppearance : TextAppearance style for text displayed on the switch thumb. [reference] +android:tabLayout : Layout used to organize each tab's content. [reference] +android:tabStripEnabled : Determines whether the strip under the tab indicators is drawn or not. [boolean] +android:tabStripLeft : Drawable used to draw the left part of the strip underneath the tabs. [reference] +android:tabStripRight : Drawable used to draw the right part of the strip underneath the tabs. [reference] +android:tag : Supply a tag for the top-level view containing a String, to be retrieved later with View.getTag() or searched for with View.findViewWithTag() . [string] +android:text : Text to display. [string] +android:textAlignment : Alignment of the text. [integer, enum] +android:textAllCaps : Present the text in ALL CAPS. [boolean] +android:textAppearance : Base text color, typeface, size, and style. [reference] +android:textColor : Text color. [color, reference] +android:textColorHighlight : Color of the text selection highlight. [color, reference] +android:textColorHint : Color of the hint text. [color, reference] +android:textColorLink : Text color for links. [color, reference] +android:textCursorDrawable : Reference to a drawable that will be drawn under the insertion cursor. [reference] +android:textDirection : Direction of the text. [integer, enum] +android:textEditNoPasteWindowLayout : Variation of textEditPasteWindowLayout displayed when the clipboard is empty. [reference] +android:textEditPasteWindowLayout : The layout of the view that is displayed on top of the cursor to paste inside a TextEdit field. [reference] +android:textEditSideNoPasteWindowLayout : Variation of textEditSidePasteWindowLayout displayed when the clipboard is empty. [reference] +android:textEditSidePasteWindowLayout : Used instead of textEditPasteWindowLayout when the window is moved on the side of the insertion cursor because it would be clipped if it were positioned on top. [reference] +android:textEditSuggestionItemLayout : Layout of the TextView item that will populate the suggestion popup window. [reference] +android:textFilterEnabled : When set to true, the list will filter results as the user types. [boolean] +android:textIsSelectable : Indicates that the content of a non-editable text can be selected. [boolean] +android:textOff : The text for the button when it is not checked. [string] +android:textOn : The text for the button when it is checked. [string] +android:textScaleX : Sets the horizontal scaling factor for the text. [float] +android:textSelectHandle : Reference to a drawable that will be used to display a text selection anchor for positioning the cursor within text. [reference] +android:textSelectHandleLeft : Reference to a drawable that will be used to display a text selection anchor on the left side of a selection region. [reference] +android:textSelectHandleRight : Reference to a drawable that will be used to display a text selection anchor on the right side of a selection region. [reference] +android:textSize : Size of the text. [dimension] +android:textStyle : Style (bold, italic, bolditalic) for the text. [flag] +android:thumb : Drawable to use as the "thumb" that switches back and forth. [reference] +android:thumbOffset : An offset for the thumb that allows it to extend out of the range of the track. [dimension] +android:thumbTextPadding : Amount of padding on either side of text within the switch thumb. [dimension] +android:tint : Set a tinting color for the image. [color] +android:topOffset : Extra offset for the handle at the top of the SlidingDrawer. [dimension] +android:track : Drawable to use as the "track" that the switch thumb slides within. [reference] +android:transcriptMode : Sets the transcript mode for the list. [enum] +android:transformPivotX : x location of the pivot point around which the view will rotate and scale. [dimension] +android:transformPivotY : y location of the pivot point around which the view will rotate and scale. [dimension] +android:translationX : translation in x of the view. [dimension] +android:translationY : translation in y of the view. [dimension] +android:typeface : Typeface (normal, sans, serif, monospace) for the text. [enum] +android:uncertainGestureColor : Color used to draw the user's strokes until we are sure it's a gesture. [color] +android:unfocusedMonthDateColor : The color for the dates of an unfocused month. [color, reference] +android:unselectedAlpha : Sets the alpha on the items that are not selected. [float] +android:useDefaultMargins : When set to true, tells GridLayout to use default margins when none are specified in a view's layout parameters. [boolean] +android:verticalScrollbarPosition : Determines which side the vertical scroll bar should be placed on. [enum] +android:verticalSpacing : Defines the default vertical spacing between rows. [dimension] +android:visibility : Controls the initial visibility of the view. [enum] +android:weekDayTextAppearance : The text appearance for the week day abbreviation of the calendar header. [reference] +android:weekNumberColor : The color for the week numbers. [color, reference] +android:weekSeparatorLineColor : The color for the separator line between weeks. [color, reference] +android:weightSum : Defines the maximum weight sum. [float] +android:width : Makes the TextView be exactly this many pixels wide. [dimension] diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-completion33.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-completion33.txt new file mode 100644 index 000000000..f9c008d25 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-completion33.txt @@ -0,0 +1,3 @@ +Code completion in completionvalues1.xml for <item name="android:allowSingleTap">^</item>: +true +false diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-completion34.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-completion34.txt new file mode 100644 index 000000000..861a41334 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-completion34.txt @@ -0,0 +1,3 @@ +Code completion in completionvalues1.xml for <item name="android:alwaysDrawnWithCache">^ false </item>: +true +false diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-completion35.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-completion35.txt new file mode 100644 index 000000000..25e8a0b1d --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-completion35.txt @@ -0,0 +1,3 @@ +Code completion in completionvalues1.xml for <item name="android:alwaysDrawnWithCache"> ^false </item>: +true +false diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-completion36.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-completion36.txt new file mode 100644 index 000000000..d85133f57 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-completion36.txt @@ -0,0 +1,2 @@ +Code completion in completionvalues1.xml for <item name="android:alwaysDrawnWithCache"> f^alse </item>: +false diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-completion37.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-completion37.txt new file mode 100644 index 000000000..1d4135106 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-completion37.txt @@ -0,0 +1,2 @@ +Code completion in completionvalues1.xml for <item name="android:orientation">h^</item>: +horizontal diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-completion38.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-completion38.txt new file mode 100644 index 000000000..8819bcd39 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-completion38.txt @@ -0,0 +1,6 @@ +Code completion in completionvalues1.xml for c^: +center_vertical +center_horizontal +center +clip_vertical +clip_horizontal diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-completion66.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-completion66.txt new file mode 100644 index 000000000..4f29a8b71 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-completion66.txt @@ -0,0 +1,7 @@ +Code completion in completionvalues1.xml for 17[^sp]: +17dp : <b>Density-independent Pixels</b> - an abstract unit that is based on the physical density of the screen. +17sp : <b>Scale-independent Pixels</b> - this is like the dp unit, but it is also scaled by the user's font size preference. +17pt : <b>Points</b> - 1/72 of an inch based on the physical size of the screen. +17mm : <b>Millimeters</b> - based on the physical size of the screen. +17in : <b>Inches</b> - based on the physical size of the screen. +17px : <b>Pixels</b> - corresponds to actual pixels on the screen. Not recommended. diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-completion67.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-completion67.txt new file mode 100644 index 000000000..4f29a8b71 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-completion67.txt @@ -0,0 +1,7 @@ +Code completion in completionvalues1.xml for 17[^sp]: +17dp : <b>Density-independent Pixels</b> - an abstract unit that is based on the physical density of the screen. +17sp : <b>Scale-independent Pixels</b> - this is like the dp unit, but it is also scaled by the user's font size preference. +17pt : <b>Points</b> - 1/72 of an inch based on the physical size of the screen. +17mm : <b>Millimeters</b> - based on the physical size of the screen. +17in : <b>Inches</b> - based on the physical size of the screen. +17px : <b>Pixels</b> - corresponds to actual pixels on the screen. Not recommended. diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-completion68.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-completion68.txt new file mode 100644 index 000000000..5aa1d43c1 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1-expected-completion68.txt @@ -0,0 +1,3 @@ +Code completion in completionvalues1.xml for [^false]: +true +false diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1.xml new file mode 100644 index 000000000..89b5f4609 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues1.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources xmlns:android="http://schemas.android.com/apk/res/android"> + <style name="stylename"> + <item name="android:textSize">17sp</item> + <item name="android:textColor">@color/title_color</item> + <item name="android:shadowColor">@an</item> + <item name="android:gravity"> </item> + <item name="gr">@color/title_color</item> + <item name="an">@color/title_color</item> + <item ></item> + <item name=""></item> + <item name="android:allowSingleTap"></item> + <item name="android:alwaysDrawnWithCache"> false </item> + <item name="android:orientation">h</item> + <item name="android:gravity"> + c + </item> + </style> +</resources> + diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues2-expected-applyCompletion45.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues2-expected-applyCompletion45.diff new file mode 100644 index 000000000..649866860 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues2-expected-applyCompletion45.diff @@ -0,0 +1,4 @@ +Code completion in completionvalues2.xml for @string/^app_name selecting @string/hello: +< <item name="main_layout5" type="string">@string/^app_name</item> +--- +> <item name="main_layout5" type="string">@string/hello^</item> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues2-expected-completion70.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues2-expected-completion70.txt new file mode 100644 index 000000000..20f8a7442 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues2-expected-completion70.txt @@ -0,0 +1,3 @@ +Code completion in completionvalues2.xml for <item name="main_layout4" type="layout">^</item>: +@android: +@layout/ diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues2-expected-completion71.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues2-expected-completion71.txt new file mode 100644 index 000000000..c491feabe --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues2-expected-completion71.txt @@ -0,0 +1,2 @@ +Code completion in completionvalues2.xml for <item name="main_layout5" type="string">@string/^app_name</item>: +@string/app_name diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues2.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues2.xml new file mode 100644 index 000000000..293abc01a --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/completionvalues2.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <item name="main_layout" type="layout">@layout/main2</item> + <item name="main_layout2" type="layout"> @layout/main_layout </item> + <item name="main_layout3" type="layout"> </item> + <item name="main_layout4" type="layout"></item> + <item name="main_layout5" type="string">@string/app_name</item> +</resources> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/drawable1-expected-completion47.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/drawable1-expected-completion47.txt new file mode 100644 index 000000000..c7f495b1b --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/drawable1-expected-completion47.txt @@ -0,0 +1,12 @@ +Code completion in drawable1.xml for ^<layer-list: +<animation-list /> : Drawable used to render several animated frames. +<bitmap /> : Drawable used to draw bitmaps. +<clip /> +<color /> : Drawable used to draw a single color. +<inset /> +<layer-list ></layer-list> : Drawable used to render several drawables stacked on top of each other. +<nine-patch /> : Drawable used to draw 9-patches. +<rotate /> : Drawable used to rotate another drawable. +<scale /> +<selector ></selector> : Drawable used to render several states. +<shape ></shape> : Drawable used to render a geometric shape, with a gradient or a solid color. diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/drawable1-expected-completion48.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/drawable1-expected-completion48.txt new file mode 100644 index 000000000..024cdebe4 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/drawable1-expected-completion48.txt @@ -0,0 +1,3 @@ +Code completion in drawable1.xml for ^xmlns:android: +android:opacity : Indicates the opacity of the layer. [enum] +xmlns:android diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/drawable1-expected-completion49.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/drawable1-expected-completion49.txt new file mode 100644 index 000000000..269fd86f0 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/drawable1-expected-completion49.txt @@ -0,0 +1,7 @@ +Code completion in drawable1.xml for <item ^></item>: +android:left : Left coordinate of the layer. [dimension] +android:top : Top coordinate of the layer. [dimension] +android:right : Right coordinate of the layer. [dimension] +android:bottom : Bottom coordinate of the layer. [dimension] +android:drawable : Drawable used to render the layer. [reference] +android:id : Identifier of the layer. [reference] diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/drawable1-expected-completion50.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/drawable1-expected-completion50.txt new file mode 100644 index 000000000..d05bc768c --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/drawable1-expected-completion50.txt @@ -0,0 +1,12 @@ +Code completion in drawable1.xml for <item >^</item>: +<animation-list /> : Drawable used to render several animated frames. +<bitmap /> : Drawable used to draw bitmaps. +<clip /> +<color /> : Drawable used to draw a single color. +<inset /> +<layer-list ></layer-list> : Drawable used to render several drawables stacked on top of each other. +<nine-patch /> : Drawable used to draw 9-patches. +<rotate /> : Drawable used to rotate another drawable. +<scale /> +<selector ></selector> : Drawable used to render several states. +<shape ></shape> : Drawable used to render a geometric shape, with a gradient or a solid color. diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/drawable1.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/drawable1.xml new file mode 100644 index 000000000..9513f1709 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/drawable1.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="utf-8"?> +<layer-list + xmlns:android="http://schemas.android.com/apk/res/android"> + <item ></item> +</layer-list> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/drawable2-expected-completion51.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/drawable2-expected-completion51.txt new file mode 100644 index 000000000..438bd768c --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/drawable2-expected-completion51.txt @@ -0,0 +1,10 @@ +Code completion in drawable2.xml for ^android:innerRadiusRatio="2": +android:visible : Indicates whether the drawable should intially be visible. [boolean] +android:dither : Enables or disables dithering. [boolean] +android:shape : Indicates what shape to fill with a gradient. [enum] +android:innerRadiusRatio : Inner radius of the ring expressed as a ratio of the ring's width. [float] +android:thicknessRatio : Thickness of the ring expressed as a ratio of the ring's width. [float] +android:innerRadius : Inner radius of the ring. [dimension] +android:thickness : Thickness of the ring. [dimension] +android:useLevel : Indicates whether the drawable's level affects the way the gradient is drawn. +xmlns:android diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/drawable2-expected-completion52.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/drawable2-expected-completion52.txt new file mode 100644 index 000000000..2a2853363 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/drawable2-expected-completion52.txt @@ -0,0 +1,7 @@ +Code completion in drawable2.xml for ^<gradient: +<corners /> : Describes the corners for the rectangle shape of a GradientDrawable. +<gradient /> : Used to describe the gradient used to fill the shape of a GradientDrawable. +<padding /> : Used to specify the optional padding of a GradientDrawable. +<size /> : Used to specify the size of the shape for GradientDrawable. +<solid /> : Used to fill the shape of GradientDrawable with a solid color. +<stroke /> : Used to describe the optional stroke of a GradientDrawable. diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/drawable2.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/drawable2.xml new file mode 100644 index 000000000..c6a672fd8 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/drawable2.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="utf-8"?> +<shape xmlns:android="http://schemas.android.com/apk/res/android" + android:innerRadiusRatio="2"> + <gradient /> +</shape> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/edithandling.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/edithandling.xml new file mode 100644 index 000000000..0488fd6f1 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/edithandling.xml @@ -0,0 +1,3 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"> +</LinearLayout> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/extractstyle1-expected-extract1b.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/extractstyle1-expected-extract1b.diff new file mode 100644 index 000000000..e21c594d1 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/extractstyle1-expected-extract1b.diff @@ -0,0 +1,34 @@ +@@ -2 +2 +- android:layout_width="wrap_content" android:layout_height="match_parent"> +- <Button android:text="Button" +- android:layout_width="wrap_content" android:layout_height="wrap_content" +- android:textColor="#FF0000" android:textSize="20pt" +- android:id="@+id/button1" android:layout_alignParentBottom="true"></Button> +- <Button android:text="Button" +- android:layout_width="wrap_content" android:layout_height="fill_parent" +- android:textColor="#FF00FF" android:textSize="20pt" +- android:id="@+id/button2" android:layout_alignParentBottom="true"></Button> ++ android:layout_width="wrap_content" ++ android:layout_height="match_parent" > ++ ++ <Button ++ android:id="@+id/button1" ++ android:layout_width="wrap_content" ++ android:layout_height="wrap_content" ++ android:layout_alignParentBottom="true" ++ android:text="Button" ++ android:textColor="#FF0000" ++ android:textSize="20pt" > ++ </Button> ++ ++ <Button ++ android:id="@+id/button2" ++ style="@style/newstyle" ++ android:layout_width="wrap_content" ++ android:layout_height="fill_parent" ++ android:layout_alignParentBottom="true" ++ android:text="Button" ++ android:textColor="#FF00FF" ++ android:textSize="20pt" > ++ </Button> ++ diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/extractstyle1-expected-extract1c.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/extractstyle1-expected-extract1c.diff new file mode 100644 index 000000000..8c12b7cde --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/extractstyle1-expected-extract1c.diff @@ -0,0 +1,31 @@ +@@ -2 +2 +- android:layout_width="wrap_content" android:layout_height="match_parent"> +- <Button android:text="Button" +- android:layout_width="wrap_content" android:layout_height="wrap_content" +- android:textColor="#FF0000" android:textSize="20pt" +- android:id="@+id/button1" android:layout_alignParentBottom="true"></Button> +- <Button android:text="Button" +- android:layout_width="wrap_content" android:layout_height="fill_parent" +- android:textColor="#FF00FF" android:textSize="20pt" +- android:id="@+id/button2" android:layout_alignParentBottom="true"></Button> ++ android:layout_width="wrap_content" ++ android:layout_height="match_parent" > ++ ++ <Button ++ android:id="@+id/button1" ++ android:layout_width="wrap_content" ++ android:layout_height="wrap_content" ++ android:layout_alignParentBottom="true" ++ android:text="Button" ++ android:textColor="#FF0000" ++ android:textSize="20pt" > ++ </Button> ++ ++ <Button ++ android:id="@+id/button2" ++ android:layout_width="wrap_content" ++ android:layout_height="fill_parent" ++ android:layout_alignParentBottom="true" ++ android:text="Button" > ++ </Button> ++ diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/extractstyle1-expected-extract1d.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/extractstyle1-expected-extract1d.diff new file mode 100644 index 000000000..c819b09aa --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/extractstyle1-expected-extract1d.diff @@ -0,0 +1,32 @@ +@@ -2 +2 +- android:layout_width="wrap_content" android:layout_height="match_parent"> +- <Button android:text="Button" +- android:layout_width="wrap_content" android:layout_height="wrap_content" +- android:textColor="#FF0000" android:textSize="20pt" +- android:id="@+id/button1" android:layout_alignParentBottom="true"></Button> +- <Button android:text="Button" +- android:layout_width="wrap_content" android:layout_height="fill_parent" +- android:textColor="#FF00FF" android:textSize="20pt" +- android:id="@+id/button2" android:layout_alignParentBottom="true"></Button> ++ android:layout_width="wrap_content" ++ android:layout_height="match_parent" > ++ ++ <Button ++ android:id="@+id/button1" ++ android:layout_width="wrap_content" ++ android:layout_height="wrap_content" ++ android:layout_alignParentBottom="true" ++ android:text="Button" ++ android:textColor="#FF0000" ++ android:textSize="20pt" > ++ </Button> ++ ++ <Button ++ android:id="@+id/button2" ++ style="@style/newstyle" ++ android:layout_width="wrap_content" ++ android:layout_height="fill_parent" ++ android:layout_alignParentBottom="true" ++ android:text="Button" > ++ </Button> ++ diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/extractstyle1-expected-extract2.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/extractstyle1-expected-extract2.diff new file mode 100644 index 000000000..c819b09aa --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/extractstyle1-expected-extract2.diff @@ -0,0 +1,32 @@ +@@ -2 +2 +- android:layout_width="wrap_content" android:layout_height="match_parent"> +- <Button android:text="Button" +- android:layout_width="wrap_content" android:layout_height="wrap_content" +- android:textColor="#FF0000" android:textSize="20pt" +- android:id="@+id/button1" android:layout_alignParentBottom="true"></Button> +- <Button android:text="Button" +- android:layout_width="wrap_content" android:layout_height="fill_parent" +- android:textColor="#FF00FF" android:textSize="20pt" +- android:id="@+id/button2" android:layout_alignParentBottom="true"></Button> ++ android:layout_width="wrap_content" ++ android:layout_height="match_parent" > ++ ++ <Button ++ android:id="@+id/button1" ++ android:layout_width="wrap_content" ++ android:layout_height="wrap_content" ++ android:layout_alignParentBottom="true" ++ android:text="Button" ++ android:textColor="#FF0000" ++ android:textSize="20pt" > ++ </Button> ++ ++ <Button ++ android:id="@+id/button2" ++ style="@style/newstyle" ++ android:layout_width="wrap_content" ++ android:layout_height="fill_parent" ++ android:layout_alignParentBottom="true" ++ android:text="Button" > ++ </Button> ++ diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/extractstyle1-expected-extract3.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/extractstyle1-expected-extract3.diff new file mode 100644 index 000000000..36186b83f --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/extractstyle1-expected-extract3.diff @@ -0,0 +1,32 @@ +@@ -2 +2 +- android:layout_width="wrap_content" android:layout_height="match_parent"> +- <Button android:text="Button" +- android:layout_width="wrap_content" android:layout_height="wrap_content" +- android:textColor="#FF0000" android:textSize="20pt" +- android:id="@+id/button1" android:layout_alignParentBottom="true"></Button> +- <Button android:text="Button" +- android:layout_width="wrap_content" android:layout_height="fill_parent" +- android:textColor="#FF00FF" android:textSize="20pt" +- android:id="@+id/button2" android:layout_alignParentBottom="true"></Button> ++ android:layout_width="wrap_content" ++ android:layout_height="match_parent" > ++ ++ <Button ++ android:id="@+id/button1" ++ style="@style/newstyle" ++ android:layout_width="wrap_content" ++ android:layout_height="wrap_content" ++ android:layout_alignParentBottom="true" ++ android:text="Button" > ++ </Button> ++ ++ <Button ++ android:id="@+id/button2" ++ style="@style/newstyle" ++ android:layout_width="wrap_content" ++ android:layout_height="fill_parent" ++ android:layout_alignParentBottom="true" ++ android:text="Button" ++ android:textColor="#FF00FF" > ++ </Button> ++ diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/extractstyle1-expected-extract4.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/extractstyle1-expected-extract4.diff new file mode 100644 index 000000000..83837f57b --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/extractstyle1-expected-extract4.diff @@ -0,0 +1,33 @@ +@@ -2 +2 +- android:layout_width="wrap_content" android:layout_height="match_parent"> +- <Button android:text="Button" +- android:layout_width="wrap_content" android:layout_height="wrap_content" +- android:textColor="#FF0000" android:textSize="20pt" +- android:id="@+id/button1" android:layout_alignParentBottom="true"></Button> +- <Button android:text="Button" +- android:layout_width="wrap_content" android:layout_height="fill_parent" +- android:textColor="#FF00FF" android:textSize="20pt" +- android:id="@+id/button2" android:layout_alignParentBottom="true"></Button> ++ android:layout_width="wrap_content" ++ android:layout_height="match_parent" > ++ ++ <Button ++ android:id="@+id/button1" ++ android:layout_width="wrap_content" ++ android:layout_height="wrap_content" ++ android:layout_alignParentBottom="true" ++ android:text="Button" ++ android:textColor="#FF0000" ++ android:textSize="20pt" > ++ </Button> ++ ++ <Button ++ android:id="@+id/button2" ++ style="@style/newstyle" ++ android:layout_width="wrap_content" ++ android:layout_height="fill_parent" ++ android:layout_alignParentBottom="true" ++ android:text="Button" ++ android:textSize="20pt" > ++ </Button> ++ diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/extractstyle1-expected-extract5.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/extractstyle1-expected-extract5.diff new file mode 100644 index 000000000..55d658ddd --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/extractstyle1-expected-extract5.diff @@ -0,0 +1,33 @@ +@@ -2 +2 +- android:layout_width="wrap_content" android:layout_height="match_parent"> +- <Button android:text="Button" +- android:layout_width="wrap_content" android:layout_height="wrap_content" +- android:textColor="#FF0000" android:textSize="20pt" +- android:id="@+id/button1" android:layout_alignParentBottom="true"></Button> +- <Button android:text="Button" +- android:layout_width="wrap_content" android:layout_height="fill_parent" +- android:textColor="#FF00FF" android:textSize="20pt" +- android:id="@+id/button2" android:layout_alignParentBottom="true"></Button> ++ android:layout_width="wrap_content" ++ android:layout_height="match_parent" > ++ ++ <Button ++ android:id="@+id/button1" ++ style="@style/newstyle" ++ android:layout_width="wrap_content" ++ android:layout_height="wrap_content" ++ android:layout_alignParentBottom="true" ++ android:text="Button" ++ android:textColor="#FF0000" > ++ </Button> ++ ++ <Button ++ android:id="@+id/button2" ++ android:layout_width="wrap_content" ++ android:layout_height="fill_parent" ++ android:layout_alignParentBottom="true" ++ android:text="Button" ++ android:textColor="#FF00FF" ++ android:textSize="20pt" > ++ </Button> ++ diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/extractstyle1-expected-extract6.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/extractstyle1-expected-extract6.diff new file mode 100644 index 000000000..1db5e3811 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/extractstyle1-expected-extract6.diff @@ -0,0 +1,6 @@ +< <Button android:text="Button" +< android:layout_width="wrap_content" android:layout_height="wrap_content" +< android:textColor="#FF0000" android:textSize="20pt" +< android:id="@+id/button1" android:layout_alignParentBottom="true"></Button> +--- +> <Button style="@style/newstyle" android:id="@+id/button1" ></Button> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/extractstyle1-expected-extract8.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/extractstyle1-expected-extract8.diff new file mode 100644 index 000000000..8c12b7cde --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/extractstyle1-expected-extract8.diff @@ -0,0 +1,31 @@ +@@ -2 +2 +- android:layout_width="wrap_content" android:layout_height="match_parent"> +- <Button android:text="Button" +- android:layout_width="wrap_content" android:layout_height="wrap_content" +- android:textColor="#FF0000" android:textSize="20pt" +- android:id="@+id/button1" android:layout_alignParentBottom="true"></Button> +- <Button android:text="Button" +- android:layout_width="wrap_content" android:layout_height="fill_parent" +- android:textColor="#FF00FF" android:textSize="20pt" +- android:id="@+id/button2" android:layout_alignParentBottom="true"></Button> ++ android:layout_width="wrap_content" ++ android:layout_height="match_parent" > ++ ++ <Button ++ android:id="@+id/button1" ++ android:layout_width="wrap_content" ++ android:layout_height="wrap_content" ++ android:layout_alignParentBottom="true" ++ android:text="Button" ++ android:textColor="#FF0000" ++ android:textSize="20pt" > ++ </Button> ++ ++ <Button ++ android:id="@+id/button2" ++ android:layout_width="wrap_content" ++ android:layout_height="fill_parent" ++ android:layout_alignParentBottom="true" ++ android:text="Button" > ++ </Button> ++ diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/extractstyle1.info b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/extractstyle1.info new file mode 100644 index 000000000..69f773989 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/extractstyle1.info @@ -0,0 +1,3 @@ +android.widget.LinearLayout [0,36,140,320] <LinearLayout> + android.widget.Button [0,0,140,62] <Button> + android.widget.Button [0,62,140,284] <Button> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/extractstyle1.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/extractstyle1.xml new file mode 100644 index 000000000..64c49b2c1 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/extractstyle1.xml @@ -0,0 +1,11 @@ +<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="wrap_content" android:layout_height="match_parent"> + <Button android:text="Button" + android:layout_width="wrap_content" android:layout_height="wrap_content" + android:textColor="#FF0000" android:textSize="20pt" + android:id="@+id/button1" android:layout_alignParentBottom="true"></Button> + <Button android:text="Button" + android:layout_width="wrap_content" android:layout_height="fill_parent" + android:textColor="#FF00FF" android:textSize="20pt" + android:id="@+id/button2" android:layout_alignParentBottom="true"></Button> +</FrameLayout> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/extractstyle2-expected-extract7.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/extractstyle2-expected-extract7.diff new file mode 100644 index 000000000..bb2960e48 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/extractstyle2-expected-extract7.diff @@ -0,0 +1,33 @@ +@@ -2 +2 +- foo:layout_width="wrap_content" foo:layout_height="match_parent" foo:orientation="vertical"> +- <Button foo:text="Button" +- foo:layout_width="wrap_content" foo:layout_height="wrap_content" +- foo:textColor="#FF0000" foo:textSize="20pt" +- foo:id="@+id/button1" foo:layout_alignParentBottom="true"></Button> +- <Button foo:text="Button" +- foo:layout_width="wrap_content" foo:layout_height="fill_parent" +- foo:textColor="#00FF00" foo:textSize="20pt" +- foo:id="@+id/button2" foo:layout_alignParentBottom="true"></Button> ++ foo:layout_width="wrap_content" ++ foo:layout_height="match_parent" ++ foo:orientation="vertical" > ++ ++ <Button ++ foo:id="@+id/button1" ++ style="@style/newstyle" ++ foo:layout_width="wrap_content" ++ foo:layout_height="wrap_content" ++ foo:layout_alignParentBottom="true" ++ foo:text="Button" ++ foo:textColor="#FF0000" > ++ </Button> ++ ++ <Button ++ foo:id="@+id/button2" ++ style="@style/newstyle" ++ foo:layout_width="wrap_content" ++ foo:layout_height="fill_parent" ++ foo:layout_alignParentBottom="true" ++ foo:text="Button" > ++ </Button> ++ diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/extractstyle2.info b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/extractstyle2.info new file mode 100644 index 000000000..69f773989 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/extractstyle2.info @@ -0,0 +1,3 @@ +android.widget.LinearLayout [0,36,140,320] <LinearLayout> + android.widget.Button [0,0,140,62] <Button> + android.widget.Button [0,62,140,284] <Button> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/extractstyle2.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/extractstyle2.xml new file mode 100644 index 000000000..3cb966f30 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/extractstyle2.xml @@ -0,0 +1,11 @@ +<LinearLayout xmlns:foo="http://schemas.android.com/apk/res/android" + foo:layout_width="wrap_content" foo:layout_height="match_parent" foo:orientation="vertical"> + <Button foo:text="Button" + foo:layout_width="wrap_content" foo:layout_height="wrap_content" + foo:textColor="#FF0000" foo:textSize="20pt" + foo:id="@+id/button1" foo:layout_alignParentBottom="true"></Button> + <Button foo:text="Button" + foo:layout_width="wrap_content" foo:layout_height="fill_parent" + foo:textColor="#00FF00" foo:textSize="20pt" + foo:id="@+id/button2" foo:layout_alignParentBottom="true"></Button> +</LinearLayout> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/fragmentlayout-expected-applyCompletion47.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/fragmentlayout-expected-applyCompletion47.diff new file mode 100644 index 000000000..3ed60f13d --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/fragmentlayout-expected-applyCompletion47.diff @@ -0,0 +1,4 @@ +Code completion in fragmentlayout.xml for class="^com selecting android.app.ListFragment: +@@ -16 +16 +- <fragment class="^com.android.eclipse.tests.TestFragment" ++ <fragment class="android.app.ListFragment^" diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/fragmentlayout-expected-complation77.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/fragmentlayout-expected-complation77.txt new file mode 100644 index 000000000..6e8687f4f --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/fragmentlayout-expected-complation77.txt @@ -0,0 +1,5 @@ +Code completion in fragmentlayout.xml for android:name="^com: +android.app.DialogFragment : <p>Implementations should override this class and implement <code><a href="/reference/android/app/Fragment.html#onCreateView(android.view.LayoutInflater, android.view.ViewGroup, android.os.Bundle)">onCreateView(LayoutInflater, ViewGroup, Bundle)</a></code> to supply ... +android.app.ListFragment : <p> ListFragment hosts a <code><a href="/reference/android/widget/ListView.html">ListView</a></code> object that can be bound to different data sources, typically either an array or a Cursor holding query results. Binding, screen layout, and row layout are discussed ... +android.preference.PreferenceFragment : <p> Furthermore, the preferences shown will follow the visual style of system preferences. It is easy to create a hierarchy of preferences (that can be shown on multiple screens) via XML. For these reasons, it is recommended to use this fragment (as a s... +android.webkit.WebViewFragment : <p> The WebView is automically paused or resumed when the Fragment is paused or resumed. </p> </div><!-- jd-descr --> <div class="jd-descr"> <h2>Summary</h2> <!-- =========== ENUM CONSTANT SUMMARY =========== --> <table id="... diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/fragmentlayout-expected-complation78.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/fragmentlayout-expected-complation78.txt new file mode 100644 index 000000000..e02637c86 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/fragmentlayout-expected-complation78.txt @@ -0,0 +1,5 @@ +Code completion in fragmentlayout.xml for class="^com: +android.app.DialogFragment : <p>Implementations should override this class and implement <code><a href="/reference/android/app/Fragment.html#onCreateView(android.view.LayoutInflater, android.view.ViewGroup, android.os.Bundle)">onCreateView(LayoutInflater, ViewGroup, Bundle)</a></code> to supply ... +android.app.ListFragment : <p> ListFragment hosts a <code><a href="/reference/android/widget/ListView.html">ListView</a></code> object that can be bound to different data sources, typically either an array or a Cursor holding query results. Binding, screen layout, and row layout are discussed ... +android.preference.PreferenceFragment : <p> Furthermore, the preferences shown will follow the visual style of system preferences. It is easy to create a hierarchy of preferences (that can be shown on multiple screens) via XML. For these reasons, it is recommended to use this fragment (as a s... +android.webkit.WebViewFragment : <p> The WebView is automically paused or resumed when the Fragment is paused or resumed. </p> </div><!-- jd-descr --> <div class="jd-descr"> <h2>Summary</h2> <!-- =========== ENUM CONSTANT SUMMARY =========== --> <table id="... diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/fragmentlayout-expected-navigate13.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/fragmentlayout-expected-navigate13.txt new file mode 100644 index 000000000..ae30d58a3 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/fragmentlayout-expected-navigate13.txt @@ -0,0 +1,12 @@ +Go To Declaration in fragmentlayout.xml for android:name="com.android.ecl^ipse.tests.TestFragment": +Open XML Declaration : [com.android.eclipse.tests.TestFragment] + + +After open, the selected text is: +[^public class TestFragment extends Fragment { + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + return null; + } +}] diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/fragmentlayout-expected-navigate14.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/fragmentlayout-expected-navigate14.txt new file mode 100644 index 000000000..0046483fc --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/fragmentlayout-expected-navigate14.txt @@ -0,0 +1,12 @@ +Go To Declaration in fragmentlayout.xml for class="com.and^roid.eclipse.tests.TestFragment": +Open XML Declaration : [com.android.eclipse.tests.TestFragment] + + +After open, the selected text is: +[^public class TestFragment extends Fragment { + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + return null; + } +}] diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/fragmentlayout.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/fragmentlayout.xml new file mode 100644 index 000000000..758599c9c --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/fragmentlayout.xml @@ -0,0 +1,19 @@ +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/home_root" + android:orientation="horizontal" + android:layout_width="fill_parent" + android:layout_height="fill_parent"> + + <LinearLayout android:orientation="vertical" + android:layout_width="wrap_content" + android:layout_height="fill_parent"> + <fragment android:name="com.android.eclipse.tests.TestFragment" + android:id="@+id/test_fragment" + android:layout_marginLeft="20dp" + android:layout_weight="1" + android:layout_width="fill_parent" + android:layout_height="0dp" /> + <fragment class="com.android.eclipse.tests.TestFragment" + android:id="@+id/test_fragment2" /> + </LinearLayout> +</LinearLayout> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/manifest-expected-complation80.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/manifest-expected-complation80.txt new file mode 100644 index 000000000..cb1d0ce9d --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/manifest-expected-complation80.txt @@ -0,0 +1,8 @@ +Code completion in manifest.xml for <activity android:name="^.: +android.accounts.AccountAuthenticatorActivity +android.app.ActivityGroup +android.app.AliasActivity +android.app.ExpandableListActivity +android.app.ListActivity +android.app.NativeActivity +android.app.TabActivity diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/manifest-expected-completion14.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/manifest-expected-completion14.txt new file mode 100644 index 000000000..478e4357c --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/manifest-expected-completion14.txt @@ -0,0 +1,10 @@ +Code completion in manifest.xml for android.permission.ACC^ESS_NETWORK_STATE: +android.permission.ACCESS_CHECKIN_PROPERTIES +android.permission.ACCESS_COARSE_LOCATION +android.permission.ACCESS_FINE_LOCATION +android.permission.ACCESS_LOCATION_EXTRA_COMMANDS +android.permission.ACCESS_MOCK_LOCATION +android.permission.ACCESS_NETWORK_STATE +android.permission.ACCESS_SURFACE_FLINGER +android.permission.ACCESS_WIFI_STATE +android.permission.ACCOUNT_MANAGER diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/manifest-expected-completion15.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/manifest-expected-completion15.txt new file mode 100644 index 000000000..c6b35386d --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/manifest-expected-completion15.txt @@ -0,0 +1,3 @@ +Code completion in manifest.xml for android.intent.category.L^AUNCHER: +android.intent.category.LAUNCHER +android.intent.category.LE_DESK_DOCK diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/manifest-expected-completion16.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/manifest-expected-completion16.txt new file mode 100644 index 000000000..f3367c72a --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/manifest-expected-completion16.txt @@ -0,0 +1,15 @@ +Code completion in manifest.xml for <^application android:i: +application : The "application" tag describes application-level components contained in the package, as well as general application attributes. +compatible-screens +instrumentation : Attributes that can be supplied in an AndroidManifest.xml "instrumentation" tag, a child of the root manifest tag. +original-package : Private tag to declare the original package name that this package is based on. +package-verifier : Attributes relating to a package verifier. +permission : The "permission" tag declares a security permission that can be used to control access from other packages to specific components or features in your package (or other packages). +permission-group : The "permission-group" tag declares a logical grouping of related permissions. +permission-tree : The "permission-tree" tag declares the base of a tree of permission values: it declares that this package has ownership of the given permission name, as well as all names underneath it (separated by '.'). +protected-broadcast : Private tag to declare system protected broadcast actions. +supports-screens : The "supports-screens" specifies the screen dimensions an application supports. +uses-configuration : The "uses-configuration" tag specifies a specific hardware configuration value used by the application. +uses-feature : The "uses-feature" tag specifies a specific feature used by the application. +uses-permission : The "uses-permission" tag requests a "permission" that the containing package must be granted in order for it to operate correctly. +uses-sdk : The "uses-sdk" tag describes the SDK features that the containing package must be running on to operate correctly. diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/manifest-expected-completion17.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/manifest-expected-completion17.txt new file mode 100644 index 000000000..8244f0a81 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/manifest-expected-completion17.txt @@ -0,0 +1,8 @@ +Code completion in manifest.xml for ^android:versionCode="1": +xmlns:android +package : This attribute gives a unique name for the package, using a Java-style naming convention to avoid name collisions. For example, applications published by Google could have names of the form com.google.app.appname +android:versionCode : Internal version code. [integer] +android:versionName : The text shown to the user to indicate the version they have. [string] +android:sharedUserId : Specify the name of a user ID that will be shared between multiple packages. [string] +android:sharedUserLabel : Specify a label for the shared user UID of this package. [reference] +android:installLocation : The default install location defined by an application. [enum] diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/manifest-expected-completion18.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/manifest-expected-completion18.txt new file mode 100644 index 000000000..12152445e --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/manifest-expected-completion18.txt @@ -0,0 +1,29 @@ +Code completion in manifest.xml for <activity android:^name=".TestActivity": +android:name : Required name of the class implementing the activity, deriving from android.app.Activity. [string]. * Required. +android:theme : The overall theme to use for an activity. [reference] +android:label : A user-legible name for the given item. [string, reference] +android:description : Descriptive text for the associated data. [reference] +android:icon : [reference] +android:logo : A Drawable resource providing an extended graphical logo for its associated item. [reference] +android:launchMode : Specify how an activity should be launched. [enum] +android:screenOrientation : Specify the orientation an activity should be run in. [enum] +android:configChanges : Specify one or more configuration changes that the activity will handle itself. [flag] +android:permission : Specify a permission that a client is required to have in order to use the associated object. [string] +android:multiprocess : Specify whether a component is allowed to have multiple instances of itself running in different processes. [boolean] +android:process : Specify a specific process that the associated code is to run in. [string] +android:taskAffinity : Specify a task name that activities have an "affinity" to. [string] +android:allowTaskReparenting : Specify that an activity can be moved out of a task it is in to the task it has an affinity for when appropriate. [boolean] +android:finishOnTaskLaunch : Specify whether an activity should be finished when its task is brought to the foreground by relaunching from the home screen. [boolean] +android:finishOnCloseSystemDialogs : Specify whether an activity should be finished when a "close system windows" request has been made. [boolean] +android:clearTaskOnLaunch : Specify whether an activity's task should be cleared when it is re-launched from the home screen. [boolean] +android:noHistory : Specify whether an activity should be kept in its history stack. [boolean] +android:alwaysRetainTaskState : Specify whether an acitivty's task state should always be maintained by the system, or if it is allowed to reset the task to its initial state in certain situations. [boolean] +android:stateNotNeeded : Indicates that an Activity does not need to have its freeze state (as returned by onSaveInstanceState retained in order to be restarted. [boolean] +android:excludeFromRecents : Indicates that an Activity should be excluded from the list of recently launched activities. [boolean] +android:enabled : Specify whether the activity is enabled or not (that is, can be instantiated by the system). [boolean] +android:exported : Flag indicating whether the given application component is available to other applications. [boolean] +android:windowSoftInputMode : Specify the default soft-input mode for the main window of this activity. [flag] +android:immersive : Flag declaring this activity to be 'immersive'; immersive activities should not be interrupted with other activities or notifications. [boolean] +android:hardwareAccelerated : <p>Flag indicating whether the application's rendering should be hardware accelerated if possible. [boolean] +android:uiOptions : Extra options for an activity's UI. [flag] +android:parentActivityName : The name of the logical parent of the activity as it appears in the manifest. [string] diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/manifest-expected-completion69.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/manifest-expected-completion69.txt new file mode 100644 index 000000000..cf7e0f4a1 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/manifest-expected-completion69.txt @@ -0,0 +1,18 @@ +Code completion in manifest.xml for <uses-sdk android:minSdkVersion="^11" />: +17 : API 17: Android 4.2 (Jelly Bean) +16 : API 16: Android 4.1 (Jelly Bean) +15 : API 15: Android 4.0.3 (IceCreamSandwich) +14 : API 14: Android 4.0 (IceCreamSandwich) +13 : API 13: Android 3.2 (Honeycomb) +12 : API 12: Android 3.1 (Honeycomb) +11 : API 11: Android 3.0 (Honeycomb) +10 : API 10: Android 2.3.3 (Gingerbread) +9 : API 9: Android 2.3 (Gingerbread) +8 : API 8: Android 2.2 (Froyo) +7 : API 7: Android 2.1 (Eclair) +6 : API 6: Android 2.0.1 (Eclair) +5 : API 5: Android 2.0 (Eclair) +4 : API 4: Android 1.6 (Donut) +3 : API 3: Android 1.5 (Cupcake) +2 : API 2: Android 1.1 +1 : API 1: Android 1.0 diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/manifest-expected-navigate10.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/manifest-expected-navigate10.txt new file mode 100644 index 000000000..c745f54d3 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/manifest-expected-navigate10.txt @@ -0,0 +1,6 @@ +Go To Declaration in manifest.xml for <uses-permission android:name="android.permission.AC^CESS_NETWORK_STATE" />: +Open XML Declaration : [android.permission.ACCESS_NETWORK_STATE] + + +After open, a browser is shown with this URL: + reference/android/Manifest.permission.html#ACCESS_NETWORK_STATE diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/manifest-expected-navigate11a.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/manifest-expected-navigate11a.txt new file mode 100644 index 000000000..eaeddf9ef --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/manifest-expected-navigate11a.txt @@ -0,0 +1,6 @@ +Go To Declaration in manifest.xml for <action android:name="android.intent.ac^tion.MAIN" />: +Open XML Declaration : [android.intent.action.MAIN] + + +After open, a browser is shown with this URL: + reference/android/content/Intent.html#ACTION_MAIN diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/manifest-expected-navigate11g.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/manifest-expected-navigate11g.txt new file mode 100644 index 000000000..9acb3308a --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/manifest-expected-navigate11g.txt @@ -0,0 +1,6 @@ +Go To Declaration in manifest.xml for <category android:name="android.intent.category.LA^UNCHER" />: +Open XML Declaration : [android.intent.category.LAUNCHER] + + +After open, a browser is shown with this URL: + reference/android/content/Intent.html#CATEGORY_LAUNCHER diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/manifest-expected-navigate9a.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/manifest-expected-navigate9a.txt new file mode 100644 index 000000000..2221e377c --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/manifest-expected-navigate9a.txt @@ -0,0 +1,6 @@ +Go To Declaration in manifest.xml for <activity android:name=".Test^Activity": +Open XML Declaration : [.TestActivity] + + +After open, the selected text is: +^<?xml version="1.0" encoding="utf-8"?> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/manifest.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/manifest.xml new file mode 100644 index 000000000..2c0024f04 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/manifest.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="utf-8"?> +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="foo.bar" + android:versionCode="1" + android:versionName="1.0"> + <uses-sdk android:minSdkVersion="11" /> + <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> + + <application android:icon="@drawable/icon" android:label="@string/app_name"> + <activity android:name=".TestActivity" + android:label="@string/app_name"> + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + <category android:name="android.intent.category.LAUNCHER" /> + </intent-filter> + </activity> + + </application> +</manifest> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/metadata.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/metadata.xml new file mode 100644 index 000000000..9262f97cd --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/metadata.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout android:id="@+id/LinearLayout1" + xmlns:android="http://schemas.android.com/apk/res/android" + android:orientation="vertical" android:layout_width="match_parent" + android:layout_height="match_parent"> + <ListView android:layout_width="match_parent" android:id="@+id/listView1" + android:layout_height="wrap_content"> + </ListView> + <Button android:text="Button" android:id="@+id/button1"/> +</LinearLayout> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/navigation1-expected-complation76.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/navigation1-expected-complation76.txt new file mode 100644 index 000000000..6b9cf5b45 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/navigation1-expected-complation76.txt @@ -0,0 +1,76 @@ +Code completion in navigation1.xml for ?android:a^ttr/alertDialogStyle: +?android:attr/ +?android:allowClearUserData +?android:authorities +?android:action +?android:alertDialogStyle +?android:absListViewStyle +?android:autoCompleteTextViewStyle +?android:autoLink +?android:activityOpenEnterAnimation +?android:activityOpenExitAnimation +?android:activityCloseEnterAnimation +?android:activityCloseExitAnimation +?android:animationCache +?android:alwaysDrawnWithCache +?android:addStatesFromChildren +?android:animationDuration +?android:antialias +?android:adjustViewBounds +?android:autoText +?android:angle +?android:animation +?android:animationOrder +?android:alphabeticShortcut +?android:alwaysRetainTaskState +?android:allowTaskReparenting +?android:apiKey +?android:allowSingleTap +?android:animateOnClick +?android:anyDensity +?android:allowBackup +?android:autoUrlDetect +?android:accountType +?android:accountPreferences +?android:author +?android:autoStart +?android:allContactsName +?android:actionBarStyle +?android:animateFirstView +?android:actionDropDownStyle +?android:actionButtonStyle +?android:actionModeBackground +?android:actionModeCloseDrawable +?android:actionBarSize +?android:animateLayoutChanges +?android:actionBarTabStyle +?android:actionBarTabBarStyle +?android:actionBarTabTextStyle +?android:actionOverflowButtonStyle +?android:actionModeCloseButtonStyle +?android:actionLayout +?android:actionViewClass +?android:activatedBackgroundIndicator +?android:alertDialogTheme +?android:autoAdvanceViewId +?android:actionModeCutDrawable +?android:actionModeCopyDrawable +?android:actionModePasteDrawable +?android:animationResolution +?android:alpha +?android:allowParallelSyncs +?android:alertDialogIcon +?android:actionMenuTextAppearance +?android:actionMenuTextColor +?android:alignmentMode +?android:actionModeSelectAllDrawable +?android:accessibilityEventTypes +?android:accessibilityFeedbackType +?android:accessibilityFlags +?android:actionBarSplitStyle +?android:actionProviderClass +?android:actionModeStyle +?android:actionBarWidgetTheme +?android:actionBarDivider +?android:actionBarItemBackground +?android:actionModeSplitBackground diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/navigation1-expected-navigate1.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/navigation1-expected-navigate1.txt new file mode 100644 index 000000000..7308a4832 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/navigation1-expected-navigate1.txt @@ -0,0 +1,7 @@ +Go To Declaration in navigation1.xml for android:text="@string/app^_name": +Open Declaration in values/strings.xml : [@string/app_name] + L/PROJECTNAME/res/values/strings.xml + + +After open, the selected text is: + [^<string name="app_name">PROJECTNAME</string>] diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/navigation1-expected-navigate12.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/navigation1-expected-navigate12.txt new file mode 100644 index 000000000..23fa07e00 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/navigation1-expected-navigate12.txt @@ -0,0 +1,6 @@ +Go To Declaration in navigation1.xml for <my.Cust^omView></my.CustomView>: +Open XML Declaration : [my.CustomView] + + +After open, the selected text is: +^<?xml version="1.0" encoding="utf-8"?> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/navigation1-expected-navigate15.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/navigation1-expected-navigate15.txt new file mode 100644 index 000000000..e36c5f30b --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/navigation1-expected-navigate15.txt @@ -0,0 +1,7 @@ +Go To Declaration in navigation1.xml for ?android:attr/alert^DialogStyle: +Open Declaration in values/attrs.xml : [?android:attr/alertDialogStyle] + data/res/values/attrs.xml + + +After open, the selected text is: + <attr name="alertDialogStyle" format="reference" />^ diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/navigation1-expected-navigate16.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/navigation1-expected-navigate16.txt new file mode 100644 index 000000000..b6f6cb2bc --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/navigation1-expected-navigate16.txt @@ -0,0 +1,7 @@ +Go To Declaration in navigation1.xml for ?android:alert^DialogStyle: +Open Declaration in values/attrs.xml : [?android:alertDialogStyle] + data/res/values/attrs.xml + + +After open, the selected text is: + <attr name="alertDialogStyle" format="reference" />^ diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/navigation1-expected-navigate2.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/navigation1-expected-navigate2.txt new file mode 100644 index 000000000..f91e1f9ae --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/navigation1-expected-navigate2.txt @@ -0,0 +1,7 @@ +Go To Declaration in navigation1.xml for marginLeft="@android:dimen/app_ico^n_size": +Open Declaration in values/dimens.xml : [@android:dimen/app_icon_size] + data/res/values/dimens.xml + + +After open, the selected text is: + <dimen name="app_icon_size">^48dip</dimen> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/navigation1-expected-navigate3.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/navigation1-expected-navigate3.txt new file mode 100644 index 000000000..53776a062 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/navigation1-expected-navigate3.txt @@ -0,0 +1,7 @@ +Go To Declaration in navigation1.xml for style="@android:style/Widget.B^utton": +Open Declaration in values/styles.xml : [@android:style/Widget.Button] + data/res/values/styles.xml + + +After open, the selected text is: + <style name="Widget.Button">^ diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/navigation1-expected-navigate4.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/navigation1-expected-navigate4.txt new file mode 100644 index 000000000..ec5ee3801 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/navigation1-expected-navigate4.txt @@ -0,0 +1,89 @@ +Go To Declaration in navigation1.xml for android:text="@android:st^ring/ok": +Open Declaration in values-en-rGB/strings.xml : [@android:string/ok] + data/res/values-en-rGB/strings.xml +Open Declaration in values/strings.xml : [@android:string/ok] + data/res/values/strings.xml +Open Declaration in values-ar/strings.xml : [@android:string/ok] + data/res/values-ar/strings.xml +Open Declaration in values-bg/strings.xml : [@android:string/ok] + data/res/values-bg/strings.xml +Open Declaration in values-ca/strings.xml : [@android:string/ok] + data/res/values-ca/strings.xml +Open Declaration in values-cs/strings.xml : [@android:string/ok] + data/res/values-cs/strings.xml +Open Declaration in values-da/strings.xml : [@android:string/ok] + data/res/values-da/strings.xml +Open Declaration in values-de/strings.xml : [@android:string/ok] + data/res/values-de/strings.xml +Open Declaration in values-el/strings.xml : [@android:string/ok] + data/res/values-el/strings.xml +Open Declaration in values-es/strings.xml : [@android:string/ok] + data/res/values-es/strings.xml +Open Declaration in values-es-rUS/strings.xml : [@android:string/ok] + data/res/values-es-rUS/strings.xml +Open Declaration in values-fa/strings.xml : [@android:string/ok] + data/res/values-fa/strings.xml +Open Declaration in values-fi/strings.xml : [@android:string/ok] + data/res/values-fi/strings.xml +Open Declaration in values-fr/strings.xml : [@android:string/ok] + data/res/values-fr/strings.xml +Open Declaration in values-hr/strings.xml : [@android:string/ok] + data/res/values-hr/strings.xml +Open Declaration in values-hu/strings.xml : [@android:string/ok] + data/res/values-hu/strings.xml +Open Declaration in values-in/strings.xml : [@android:string/ok] + data/res/values-in/strings.xml +Open Declaration in values-it/strings.xml : [@android:string/ok] + data/res/values-it/strings.xml +Open Declaration in values-iw/strings.xml : [@android:string/ok] + data/res/values-iw/strings.xml +Open Declaration in values-ja/strings.xml : [@android:string/ok] + data/res/values-ja/strings.xml +Open Declaration in values-ko/strings.xml : [@android:string/ok] + data/res/values-ko/strings.xml +Open Declaration in values-lt/strings.xml : [@android:string/ok] + data/res/values-lt/strings.xml +Open Declaration in values-lv/strings.xml : [@android:string/ok] + data/res/values-lv/strings.xml +Open Declaration in values-nb/strings.xml : [@android:string/ok] + data/res/values-nb/strings.xml +Open Declaration in values-nl/strings.xml : [@android:string/ok] + data/res/values-nl/strings.xml +Open Declaration in values-pl/strings.xml : [@android:string/ok] + data/res/values-pl/strings.xml +Open Declaration in values-pt/strings.xml : [@android:string/ok] + data/res/values-pt/strings.xml +Open Declaration in values-pt-rPT/strings.xml : [@android:string/ok] + data/res/values-pt-rPT/strings.xml +Open Declaration in values-rm/strings.xml : [@android:string/ok] + data/res/values-rm/strings.xml +Open Declaration in values-ro/strings.xml : [@android:string/ok] + data/res/values-ro/strings.xml +Open Declaration in values-ru/strings.xml : [@android:string/ok] + data/res/values-ru/strings.xml +Open Declaration in values-sk/strings.xml : [@android:string/ok] + data/res/values-sk/strings.xml +Open Declaration in values-sl/strings.xml : [@android:string/ok] + data/res/values-sl/strings.xml +Open Declaration in values-sr/strings.xml : [@android:string/ok] + data/res/values-sr/strings.xml +Open Declaration in values-sv/strings.xml : [@android:string/ok] + data/res/values-sv/strings.xml +Open Declaration in values-th/strings.xml : [@android:string/ok] + data/res/values-th/strings.xml +Open Declaration in values-tl/strings.xml : [@android:string/ok] + data/res/values-tl/strings.xml +Open Declaration in values-tr/strings.xml : [@android:string/ok] + data/res/values-tr/strings.xml +Open Declaration in values-uk/strings.xml : [@android:string/ok] + data/res/values-uk/strings.xml +Open Declaration in values-vi/strings.xml : [@android:string/ok] + data/res/values-vi/strings.xml +Open Declaration in values-zh-rCN/strings.xml : [@android:string/ok] + data/res/values-zh-rCN/strings.xml +Open Declaration in values-zh-rTW/strings.xml : [@android:string/ok] + data/res/values-zh-rTW/strings.xml + + +After open, the selected text is: + <string name="ok" msgid="5970060430562524910">^"OK"</string> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/navigation1.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/navigation1.xml new file mode 100644 index 000000000..c5b292e7b --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/navigation1.xml @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout + xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent"> + <Button + android:text="@string/app_name" + android:layout_marginLeft="@android:dimen/app_icon_size" + style="@android:style/Widget.Button" + android:id="@+id/button1" + ></Button> + <my.CustomView></my.CustomView> + <EditText + android:text="@android:string/ok" + </EditText> + <EditText android:text="?android:attr/alertDialogStyle" /> + <EditText android:text="?android:alertDialogStyle" /> +</LinearLayout> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/navigationstyles-expected-extract2.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/navigationstyles-expected-extract2.diff new file mode 100644 index 000000000..8890f79ea --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/navigationstyles-expected-extract2.diff @@ -0,0 +1,5 @@ +@@ -28 +28 ++ <style name="newstyle"> ++ <item name="android:textColor">#FF00FF</item> ++ <item name="android:textSize">20pt</item> ++ </style> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/navigationstyles-expected-navigate5.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/navigationstyles-expected-navigate5.txt new file mode 100644 index 000000000..15c91d1be --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/navigationstyles-expected-navigate5.txt @@ -0,0 +1,7 @@ +Go To Declaration in navigationstyles.xml for parent="android:Theme.Li^ght">: +Open Declaration in values/themes.xml : [android:Theme.Light] + data/res/values/themes.xml + + +After open, the selected text is: + <style name="Theme.Light">^ diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/navigationstyles-expected-navigate6.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/navigationstyles-expected-navigate6.txt new file mode 100644 index 000000000..5a4f40aa4 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/navigationstyles-expected-navigate6.txt @@ -0,0 +1,7 @@ +Go To Declaration in navigationstyles.xml for parent="android:The^me.Light">: +Open Declaration in values/themes.xml : [android:Theme] + data/res/values/themes.xml + + +After open, the selected text is: + <style name="Theme">^ diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/navigationstyles-expected-navigate7.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/navigationstyles-expected-navigate7.txt new file mode 100644 index 000000000..8f7eb46b8 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/navigationstyles-expected-navigate7.txt @@ -0,0 +1,7 @@ +Go To Declaration in navigationstyles.xml for popupBackground">@android:drawable/spinner_dr^opdown_background</item>: +Open Declaration in drawable/spinner_dropdown_background.xml : [@android:drawable/spinner_dropdown_background] + data/res/drawable/spinner_dropdown_background.xml + + +After open, the selected text is: +^<?xml version="1.0" encoding="utf-8"?> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/navigationstyles-expected-navigate8.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/navigationstyles-expected-navigate8.txt new file mode 100644 index 000000000..b74c67681 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/navigationstyles-expected-navigate8.txt @@ -0,0 +1,7 @@ +Go To Declaration in navigationstyles.xml for colorBackground"> @color/cust^om_theme_color </item>: +Open Declaration in values/navigationstyles.xml : [@color/custom_theme_color] + L/PROJECTNAME/res/values/navigationstyles.xml + + +After open, the selected text is: + [^<color name="custom_theme_color">#b0b0ff</color>] diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/navigationstyles.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/navigationstyles.xml new file mode 100644 index 000000000..da4bbf289 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/navigationstyles.xml @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <color name="custom_theme_color">#b0b0ff</color> + <style name="CustomTheme" parent="android:Theme.Light"> + <item name="android:windowBackground">@color/custom_theme_color</item> + <item name="android:colorBackground"> @color/custom_theme_color </item> + </style> + + <style name="BrowserTheme" parent="@android:Theme.Black"> + <item name="android:autoCompleteTextViewStyle">@style/AutoCompleteTextView</item> + <item name="android:windowNoTitle">true</item> + </style> + + <style name="AutoCompleteTextView"> + <item name="android:focusable">true</item> + <item name="android:focusableInTouchMode">true</item> + <item name="android:clickable">true</item> + <item name="android:completionHintView">@android:layout/simple_dropdown_item_1line</item> + <item name="android:textAppearance">?android:attr/textAppearanceLargeInverse</item> + <item name="android:completionThreshold">2</item> + <item name="android:dropDownSelector">@android:drawable/list_selector_background</item> + <item name="android:popupBackground">@android:drawable/spinner_dropdown_background</item> + </style> + + <style name="CustomTitle" parent="@android:Theme"> + <item name="android:windowTitleSize">60dip</item> + </style> +</resources> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/newlayout1-expected-extract1.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/newlayout1-expected-extract1.xml new file mode 100644 index 000000000..2a0e9477c --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/newlayout1-expected-extract1.xml @@ -0,0 +1,2 @@ +<?xml version="1.0" encoding="utf-8"?> +<Button xmlns:android="http://schemas.android.com/apk/res/android" android:text="Button" android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/newlayout2-expected-extract2.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/newlayout2-expected-extract2.xml new file mode 100644 index 000000000..b2d1789aa --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/newlayout2-expected-extract2.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8"?> +<merge xmlns:android="http://schemas.android.com/apk/res/android"> + <ImageView android:id="@+id/android_logo" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/android_button" android:focusable="false" android:clickable="false" android:layout_weight="1.0" /> + <Button android:text="Button" android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button> +</merge> + diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/newlayout3-expected-extract3.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/newlayout3-expected-extract3.xml new file mode 100644 index 000000000..6ba61c838 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/newlayout3-expected-extract3.xml @@ -0,0 +1,2 @@ +<?xml version="1.0" encoding="utf-8"?> +<Button xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:id="@+id/button3" android:layout_height="wrap_content" android:text="Button" ></Button> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/newlayout3-expected-extract4.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/newlayout3-expected-extract4.xml new file mode 100644 index 000000000..ee8568e68 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/newlayout3-expected-extract4.xml @@ -0,0 +1,2 @@ +<?xml version="1.0" encoding="utf-8"?> +<ImageView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/android_logo" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/android_button" android:focusable="false" android:clickable="false" /> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/newlayout3-expected-extract5.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/newlayout3-expected-extract5.xml new file mode 100644 index 000000000..be5706645 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/newlayout3-expected-extract5.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8"?> +<merge xmlns:android="http://schemas.android.com/apk/res/android"> + <Button android:text="Button" android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button> + <ImageView android:id="@+id/android_logo" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/android_button" android:focusable="false" android:clickable="false" android:layout_weight="1.0" /> +</merge> + diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/newlayout6-expected-extract6.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/newlayout6-expected-extract6.diff new file mode 100644 index 000000000..6772a8fa2 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/newlayout6-expected-extract6.diff @@ -0,0 +1,12 @@ +@@ -1 +1 +- +@@ -2 +1 ++ <?xml version="1.0" encoding="utf-8"?> ++ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="wrap_content" android:id="@+id/linearLayout4" android:layout_width="match_parent"> ++ <LinearLayout android:layout_height="match_parent" android:id="@+id/linearLayout5" android:layout_width="wrap_content"> ++ <LinearLayout android:layout_height="match_parent" android:id="@+id/linearLayout6" android:layout_width="wrap_content"> ++ <!-- Comment --> ++ <Button android:text="Button" android:id="@+id/button6" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button> ++ </LinearLayout> ++ </LinearLayout> ++ </LinearLayout> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/newlayout6-expected-extract7.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/newlayout6-expected-extract7.diff new file mode 100644 index 000000000..d0fdc92e5 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/newlayout6-expected-extract7.diff @@ -0,0 +1,29 @@ +@@ -1 +1 ++ <?xml version="1.0" encoding="utf-8"?> ++ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" ++ android:id="@+id/linearLayout4" ++ android:layout_width="match_parent" ++ android:layout_height="wrap_content" > +@@ -2 +7 ++ <LinearLayout ++ android:id="@+id/linearLayout5" ++ android:layout_width="wrap_content" ++ android:layout_height="match_parent" > ++ ++ <LinearLayout ++ android:id="@+id/linearLayout6" ++ android:layout_width="wrap_content" ++ android:layout_height="match_parent" > ++ ++ <!-- Comment --> ++ ++ <Button ++ android:id="@+id/button6" ++ android:layout_width="wrap_content" ++ android:layout_height="wrap_content" ++ android:text="Button" > ++ </Button> ++ </LinearLayout> ++ </LinearLayout> ++ ++ </LinearLayout> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/newstyles-expected-extract1.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/newstyles-expected-extract1.diff new file mode 100644 index 000000000..0949fbd01 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/newstyles-expected-extract1.diff @@ -0,0 +1,10 @@ +@@ -1 +1 +- +@@ -2 +1 ++ <?xml version="1.0" encoding="utf-8"?> ++ <resources xmlns:android="http://schemas.android.com/apk/res/android"> ++ <style name="newstyle"> ++ <item name="android:textColor">#FF00FF</item> ++ <item name="android:textSize">20pt</item> ++ </style> ++ </resources> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/newstyles2-expected-extract1b.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/newstyles2-expected-extract1b.diff new file mode 100644 index 000000000..0949fbd01 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/newstyles2-expected-extract1b.diff @@ -0,0 +1,10 @@ +@@ -1 +1 +- +@@ -2 +1 ++ <?xml version="1.0" encoding="utf-8"?> ++ <resources xmlns:android="http://schemas.android.com/apk/res/android"> ++ <style name="newstyle"> ++ <item name="android:textColor">#FF00FF</item> ++ <item name="android:textSize">20pt</item> ++ </style> ++ </resources> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/newstyles3-expected-extract1c.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/newstyles3-expected-extract1c.diff new file mode 100644 index 000000000..0949fbd01 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/newstyles3-expected-extract1c.diff @@ -0,0 +1,10 @@ +@@ -1 +1 +- +@@ -2 +1 ++ <?xml version="1.0" encoding="utf-8"?> ++ <resources xmlns:android="http://schemas.android.com/apk/res/android"> ++ <style name="newstyle"> ++ <item name="android:textColor">#FF00FF</item> ++ <item name="android:textSize">20pt</item> ++ </style> ++ </resources> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/newstyles3-expected-extract8.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/newstyles3-expected-extract8.diff new file mode 100644 index 000000000..e8b553ec9 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/newstyles3-expected-extract8.diff @@ -0,0 +1,10 @@ +@@ -1 +1 +- +@@ -2 +1 ++ <?xml version="1.0" encoding="utf-8"?> ++ <resources xmlns:android="http://schemas.android.com/apk/res/android"> ++ <style name="newstyle" parent="android:Widget.Button"> ++ <item name="android:textColor">#FF00FF</item> ++ <item name="android:textSize">20pt</item> ++ </style> ++ </resources> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/newstyles4-expected-extract1d.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/newstyles4-expected-extract1d.diff new file mode 100644 index 000000000..0949fbd01 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/newstyles4-expected-extract1d.diff @@ -0,0 +1,10 @@ +@@ -1 +1 +- +@@ -2 +1 ++ <?xml version="1.0" encoding="utf-8"?> ++ <resources xmlns:android="http://schemas.android.com/apk/res/android"> ++ <style name="newstyle"> ++ <item name="android:textColor">#FF00FF</item> ++ <item name="android:textSize">20pt</item> ++ </style> ++ </resources> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/newstyles4-expected-extract3.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/newstyles4-expected-extract3.diff new file mode 100644 index 000000000..88a94e7e0 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/newstyles4-expected-extract3.diff @@ -0,0 +1,10 @@ +@@ -1 +1 +- +@@ -2 +1 ++ <?xml version="1.0" encoding="utf-8"?> ++ <resources xmlns:android="http://schemas.android.com/apk/res/android"> ++ <style name="newstyle"> ++ <item name="android:textColor">#FF0000</item> ++ <item name="android:textSize">20pt</item> ++ </style> ++ </resources> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/newstyles5-expected-extract4.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/newstyles5-expected-extract4.diff new file mode 100644 index 000000000..49043b93c --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/newstyles5-expected-extract4.diff @@ -0,0 +1,9 @@ +@@ -1 +1 +- +@@ -2 +1 ++ <?xml version="1.0" encoding="utf-8"?> ++ <resources xmlns:android="http://schemas.android.com/apk/res/android"> ++ <style name="newstyle"> ++ <item name="android:textColor">#FF00FF</item> ++ </style> ++ </resources> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/newstyles6-expected-extract5.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/newstyles6-expected-extract5.diff new file mode 100644 index 000000000..49ab2c3ee --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/newstyles6-expected-extract5.diff @@ -0,0 +1,9 @@ +@@ -1 +1 +- +@@ -2 +1 ++ <?xml version="1.0" encoding="utf-8"?> ++ <resources xmlns:android="http://schemas.android.com/apk/res/android"> ++ <style name="newstyle"> ++ <item name="android:textSize">20pt</item> ++ </style> ++ </resources> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/newstyles7-expected-extract6.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/newstyles7-expected-extract6.diff new file mode 100644 index 000000000..51f0812c9 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/newstyles7-expected-extract6.diff @@ -0,0 +1,13 @@ +< +--- +> <?xml version="1.0" encoding="utf-8"?> +> <resources xmlns:android="http://schemas.android.com/apk/res/android"> +> <style name="newstyle"> +> <item name="android:layout_alignParentBottom">true</item> +> <item name="android:layout_height">wrap_content</item> +> <item name="android:layout_width">wrap_content</item> +> <item name="android:text">Button</item> +> <item name="android:textColor">#FF0000</item> +> <item name="android:textSize">20pt</item> +> </style> +> </resources> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/newstyles8-expected-extract7.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/newstyles8-expected-extract7.diff new file mode 100644 index 000000000..6bcd6ffd4 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/newstyles8-expected-extract7.diff @@ -0,0 +1,10 @@ +@@ -1 +1 +- +@@ -2 +1 ++ <?xml version="1.0" encoding="utf-8"?> ++ <resources xmlns:android="http://schemas.android.com/apk/res/android"> ++ <style name="newstyle"> ++ <item name="android:textColor">#00FF00</item> ++ <item name="android:textSize">20pt</item> ++ </style> ++ </resources> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/quickfix1-expected-quickFix1.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/quickfix1-expected-quickFix1.xml new file mode 100644 index 000000000..a51abf407 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/quickfix1-expected-quickFix1.xml @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + + <string name="app_name">PROJECTNAME</string> + <string name="firststring">[^TODO]</string> + +</resources>
\ No newline at end of file diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/quickfix1-expected-quickFix2.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/quickfix1-expected-quickFix2.xml new file mode 100644 index 000000000..a0d04fb6e --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/quickfix1-expected-quickFix2.xml @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <dimen name="testdimen">[^1dp]</dimen> +</resources> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/quickfix1-expected-quickFix3.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/quickfix1-expected-quickFix3.xml new file mode 100644 index 000000000..900c42064 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/quickfix1-expected-quickFix3.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical" > + ^ + +</LinearLayout>
\ No newline at end of file diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/quickfix1.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/quickfix1.xml new file mode 100644 index 000000000..927c8d1db --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/quickfix1.xml @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout + xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent"> + + <Button android:text="@string/firststring" + android:id="@+id/button1" + android:layout_width="@dimen/testdimen" + android:layout_height="wrap_content"> + </Button> + + <include layout="@layout/testlayout" android:layout_width="wrap_content" android:layout_height="wrap_content"/> + +</LinearLayout> + diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/quickfix2-expected-quickFix4.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/quickfix2-expected-quickFix4.xml new file mode 100644 index 000000000..7b638c645 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/quickfix2-expected-quickFix4.xml @@ -0,0 +1,4 @@ +@@ -5 +5 +- <color android:color="#0000000"/> +@@ -6 +5 ++ <color android:color="#0000000" xmlns:android="http://schemas.android.com/apk/res/android"/> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/quickfix2.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/quickfix2.xml new file mode 100644 index 000000000..4f2a925a5 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/quickfix2.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="utf-8"?> + <!-- + Random comment here + --> +<color android:color="#0000000"/> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound1-expected-1.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound1-expected-1.xml new file mode 100644 index 000000000..e72638f57 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound1-expected-1.xml @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + android:orientation="vertical" > + + <TextView + android:id="@+id/TextView1" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:drawableTop="@drawable/ic_launcher" + android:gravity="center" + android:text="Hello World" > + </TextView> + +</LinearLayout>
\ No newline at end of file diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound1.info b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound1.info new file mode 100644 index 000000000..4f0aea55e --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound1.info @@ -0,0 +1,4 @@ +android.widget.LinearLayout [0,121,800,480] <LinearLayout> + android.widget.LinearLayout [0,0,109,97] <LinearLayout> + android.widget.ImageView [18,0,90,72] <ImageView> + android.widget.TextView [0,72,109,97] <TextView> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound1.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound1.xml new file mode 100644 index 000000000..e4f5bf20e --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound1.xml @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + android:orientation="vertical" > + + <LinearLayout + android:id="@+id/layout1" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:gravity="center" + android:orientation="vertical" > + + <ImageView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:src="@drawable/ic_launcher" /> + + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="Hello World" /> + </LinearLayout> + +</LinearLayout> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound2-expected-2.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound2-expected-2.xml new file mode 100644 index 000000000..2b9d338d1 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound2-expected-2.xml @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + android:orientation="vertical" > + + <TextView + android:id="@+id/TextView1" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:drawableBottom="@drawable/ic_launcher" + android:gravity="center" + android:text="Hello World" > + </TextView> + +</LinearLayout>
\ No newline at end of file diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound2.info b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound2.info new file mode 100644 index 000000000..37084fb88 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound2.info @@ -0,0 +1,5 @@ +android.widget.LinearLayout [0,121,800,480] <LinearLayout> + android.widget.LinearLayout [0,0,109,97] <LinearLayout> + android.widget.TextView [0,0,109,25] <TextView> + android.widget.ImageView [18,25,90,97] <ImageView> + diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound2.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound2.xml new file mode 100644 index 000000000..c24fb211c --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound2.xml @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + android:orientation="vertical" > + + <LinearLayout + android:id="@+id/layout2" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:gravity="center" + android:orientation="vertical" > + + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="Hello World" /> + + <ImageView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:src="@drawable/ic_launcher" /> + </LinearLayout> + +</LinearLayout> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound3-expected-3.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound3-expected-3.xml new file mode 100644 index 000000000..ac8ffa8ce --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound3-expected-3.xml @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + android:orientation="vertical" > + + <TextView + android:id="@+id/TextView1" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:drawableLeft="@drawable/ic_launcher" + android:gravity="center" + android:text="Hello World" > + </TextView> + +</LinearLayout>
\ No newline at end of file diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound3.info b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound3.info new file mode 100644 index 000000000..01d1127f1 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound3.info @@ -0,0 +1,4 @@ +android.widget.LinearLayout [0,121,800,480] <LinearLayout> + android.widget.LinearLayout [0,0,181,72] <LinearLayout> + android.widget.ImageView [0,0,72,72] <ImageView> + android.widget.TextView [72,23,181,48] <TextView> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound3.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound3.xml new file mode 100644 index 000000000..2444e4830 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound3.xml @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + android:orientation="vertical" > + + <LinearLayout + android:id="@+id/layout3" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:gravity="center" + android:orientation="horizontal" > + + <ImageView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:src="@drawable/ic_launcher" /> + + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="Hello World" /> + </LinearLayout> + +</LinearLayout> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound4-expected-4.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound4-expected-4.xml new file mode 100644 index 000000000..af9b1c922 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound4-expected-4.xml @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + android:orientation="vertical" > + + <TextView + android:id="@+id/TextView1" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:drawableRight="@drawable/ic_launcher" + android:gravity="center" + android:text="Hello World" > + </TextView> + +</LinearLayout>
\ No newline at end of file diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound4.info b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound4.info new file mode 100644 index 000000000..4b39be81e --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound4.info @@ -0,0 +1,4 @@ +android.widget.LinearLayout [0,121,800,480] <LinearLayout> + android.widget.LinearLayout [0,0,181,72] <LinearLayout> + android.widget.TextView [0,23,109,48] <TextView> + android.widget.ImageView [109,0,181,72] <ImageView> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound4.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound4.xml new file mode 100644 index 000000000..2f6afd2f7 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound4.xml @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + android:orientation="vertical" > + + <LinearLayout + android:id="@+id/layout4" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:gravity="center" + android:orientation="horizontal" > + + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="Hello World" /> + + <ImageView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:src="@drawable/ic_launcher" /> + </LinearLayout> + +</LinearLayout> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound5-expected-7.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound5-expected-7.xml new file mode 100644 index 000000000..e909811cf --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound5-expected-7.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="utf-8"?> +<TextView xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/TextView1" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:drawableBottom="@drawable/ic_launcher" + android:text="Hello World" > + +</TextView>
\ No newline at end of file diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound5.info b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound5.info new file mode 100644 index 000000000..8eb5c4b86 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound5.info @@ -0,0 +1,3 @@ +android.widget.LinearLayout [0,74,480,800] <LinearLayout> + android.widget.TextView [0,0,107,26] <TextView> + android.widget.ImageView [0,26,72,98] <ImageView> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound5.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound5.xml new file mode 100644 index 000000000..49c0594da --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound5.xml @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + android:id="@+id/layout" + android:orientation="vertical" > + + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="Hello World" /> + + <ImageView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:src="@drawable/ic_launcher" /> + +</LinearLayout> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound6-expected-8.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound6-expected-8.xml new file mode 100644 index 000000000..1ef5d78c6 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound6-expected-8.xml @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + android:orientation="vertical" > + + <TextView + android:id="@+id/TextView1" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:drawableLeft="@drawable/ic_launcher" + android:drawablePadding="@android:dimen/thumbnail_width" + android:gravity="center" + android:text="Hello World" > + </TextView> + +</LinearLayout>
\ No newline at end of file diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound6.info b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound6.info new file mode 100644 index 000000000..4f0aea55e --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound6.info @@ -0,0 +1,4 @@ +android.widget.LinearLayout [0,121,800,480] <LinearLayout> + android.widget.LinearLayout [0,0,109,97] <LinearLayout> + android.widget.ImageView [18,0,90,72] <ImageView> + android.widget.TextView [0,72,109,97] <TextView> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound6.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound6.xml new file mode 100644 index 000000000..94a363ba5 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound6.xml @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + android:orientation="vertical" > + + <LinearLayout + android:id="@+id/layout1" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:gravity="center" > + + <ImageView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginRight="@android:dimen/thumbnail_width" + android:src="@drawable/ic_launcher" /> + + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="Hello World" /> + </LinearLayout> + +</LinearLayout> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound7-expected-9.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound7-expected-9.xml new file mode 100644 index 000000000..1b2a8643e --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound7-expected-9.xml @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + android:orientation="vertical" > + + <TextView + android:id="@+id/TextView1" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:drawablePadding="35dp" + android:drawableTop="@drawable/ic_launcher" + android:gravity="center" + android:text="Hello World" > + </TextView> + +</LinearLayout>
\ No newline at end of file diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound7.info b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound7.info new file mode 100644 index 000000000..4f0aea55e --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound7.info @@ -0,0 +1,4 @@ +android.widget.LinearLayout [0,121,800,480] <LinearLayout> + android.widget.LinearLayout [0,0,109,97] <LinearLayout> + android.widget.ImageView [18,0,90,72] <ImageView> + android.widget.TextView [0,72,109,97] <TextView> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound7.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound7.xml new file mode 100644 index 000000000..46393fe0e --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound7.xml @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + android:orientation="vertical" > + + <LinearLayout + android:id="@+id/layout1" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:gravity="center" + android:orientation="vertical" > + + <ImageView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginBottom="10dp" + android:src="@drawable/ic_launcher" /> + + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginTop="25dp" + android:text="Hello World" /> + </LinearLayout> + +</LinearLayout> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound_all-expected-5.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound_all-expected-5.xml new file mode 100644 index 000000000..35bebf5f1 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound_all-expected-5.xml @@ -0,0 +1,73 @@ +<?xml version="1.0" encoding="utf-8"?> +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/RelativeLayout1" + android:layout_width="fill_parent" + android:layout_height="fill_parent" > + + <LinearLayout + android:id="@+id/layout1" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:gravity="center" + android:orientation="vertical" > + + <ImageView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:src="@drawable/ic_launcher" /> + + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="Hello World" /> + </LinearLayout> + + <TextView + android:id="@+id/textView2" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_below="@+id/layout1" + android:drawableBottom="@drawable/ic_launcher" + android:gravity="center" + android:text="Hello World" > + </TextView> + + <LinearLayout + android:id="@+id/layout3" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_below="@+id/textView2" + android:gravity="center" + android:orientation="horizontal" > + + <ImageView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:src="@drawable/ic_launcher" /> + + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="Hello World" /> + </LinearLayout> + + <LinearLayout + android:id="@+id/layout4" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_below="@+id/layout3" + android:gravity="center" + android:orientation="horizontal" > + + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="Hello World" /> + + <ImageView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:src="@drawable/ic_launcher" /> + </LinearLayout> + +</RelativeLayout>
\ No newline at end of file diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound_all-expected-6.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound_all-expected-6.xml new file mode 100644 index 000000000..6d9925674 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound_all-expected-6.xml @@ -0,0 +1,74 @@ +<?xml version="1.0" encoding="utf-8"?> +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/RelativeLayout1" + android:layout_width="fill_parent" + android:layout_height="fill_parent" > + + <LinearLayout + android:id="@+id/layout1" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:gravity="center" + android:orientation="vertical" > + + <ImageView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:src="@drawable/ic_launcher" /> + + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="Hello World" /> + </LinearLayout> + + <LinearLayout + android:id="@+id/layout2" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_below="@+id/layout1" + android:gravity="center" + android:orientation="vertical" > + + <TextView + android:id="@+id/textView2" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="Hello World" /> + + <ImageView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:src="@drawable/ic_launcher" /> + </LinearLayout> + + <TextView + android:id="@+id/TextView1" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_below="@+id/layout2" + android:drawableLeft="@drawable/ic_launcher" + android:gravity="center" + android:text="Hello World" > + </TextView> + + <LinearLayout + android:id="@+id/layout4" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_below="@+id/TextView1" + android:gravity="center" + android:orientation="horizontal" > + + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="Hello World" /> + + <ImageView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:src="@drawable/ic_launcher" /> + </LinearLayout> + +</RelativeLayout>
\ No newline at end of file diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound_all.info b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound_all.info new file mode 100644 index 000000000..57508bd72 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound_all.info @@ -0,0 +1,13 @@ +android.widget.RelativeLayout [0,121,800,480] <RelativeLayout> + android.widget.LinearLayout [0,0,109,97] <LinearLayout> + android.widget.ImageView [18,0,90,72] <ImageView> + android.widget.TextView [0,72,109,97] <TextView> + android.widget.LinearLayout [0,97,109,194] <LinearLayout> + android.widget.TextView [0,0,109,25] <TextView> + android.widget.ImageView [18,25,90,97] <ImageView> + android.widget.LinearLayout [0,194,181,266] <LinearLayout> + android.widget.ImageView [0,0,72,72] <ImageView> + android.widget.TextView [72,23,181,48] <TextView> + android.widget.LinearLayout [0,266,181,338] <LinearLayout> + android.widget.TextView [0,23,109,48] <TextView> + android.widget.ImageView [109,0,181,72] <ImageView> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound_all.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound_all.xml new file mode 100644 index 000000000..0406b171d --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/refactoring/usecompound/compound_all.xml @@ -0,0 +1,83 @@ +<?xml version="1.0" encoding="utf-8"?> +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/RelativeLayout1" + android:layout_width="fill_parent" + android:layout_height="fill_parent" > + + <LinearLayout + android:id="@+id/layout1" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:gravity="center" + android:orientation="vertical" > + + <ImageView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:src="@drawable/ic_launcher" /> + + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="Hello World" /> + </LinearLayout> + + <LinearLayout + android:id="@+id/layout2" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_below="@+id/layout1" + android:gravity="center" + android:orientation="vertical" > + + <TextView + android:id="@+id/textView2" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="Hello World" /> + + <ImageView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:src="@drawable/ic_launcher" /> + </LinearLayout> + + <LinearLayout + android:id="@+id/layout3" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_below="@+id/layout2" + android:gravity="center" + android:orientation="horizontal" > + + <ImageView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:src="@drawable/ic_launcher" /> + + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="Hello World" /> + </LinearLayout> + + <LinearLayout + android:id="@+id/layout4" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_below="@+id/layout3" + android:gravity="center" + android:orientation="horizontal" > + + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="Hello World" /> + + <ImageView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:src="@drawable/ic_launcher" /> + </LinearLayout> + +</RelativeLayout> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample10-expected-convertFromGrid.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample10-expected-convertFromGrid.xml new file mode 100644 index 000000000..98e1f36f4 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample10-expected-convertFromGrid.xml @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/LinearLayout1" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:columnCount="2" + android:orientation="horizontal" > + + <Button + android:id="@+id/button1" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="Button" /> + + <RadioButton + android:id="@+id/radioButton1" + android:layout_width="150dp" + android:layout_height="wrap_content" + android:layout_column="0" + android:layout_row="1" + android:text="RadioButton" /> + + <RadioButton + android:id="@+id/radioButton2" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="RadioButton" /> + + <CheckBox + android:id="@+id/checkBox1" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="CheckBox" /> + +</LinearLayout>
\ No newline at end of file diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample10-expected-initialAttributes.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample10-expected-initialAttributes.xml new file mode 100644 index 000000000..aa8ecdac2 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample10-expected-initialAttributes.xml @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/LinearLayout1" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:columnCount="2" + android:orientation="vertical" > + + <Button + android:id="@+id/button1" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="Button" /> + + <RadioButton + android:id="@+id/radioButton1" + android:layout_width="150dp" + android:layout_height="wrap_content" + android:layout_column="0" + android:layout_row="1" + android:text="RadioButton" /> + + <RadioButton + android:id="@+id/radioButton2" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="RadioButton" /> + + <CheckBox + android:id="@+id/checkBox1" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="CheckBox" /> + +</LinearLayout>
\ No newline at end of file diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample10.info b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample10.info new file mode 100644 index 000000000..c964b0eba --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample10.info @@ -0,0 +1,5 @@ +android.widget.GridLayout [0,73,320,480] <GridLayout> + android.widget.Button [0,0,79,48] <Button> + android.widget.RadioButton [0,48,150,86] <RadioButton> + android.widget.RadioButton [150,48,273,86] <RadioButton> + android.widget.CheckBox [0,86,107,124] <CheckBox> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample10.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample10.xml new file mode 100644 index 000000000..1fcaab569 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample10.xml @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="utf-8"?> +<GridLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/GridLayout1" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:columnCount="2" + android:orientation="horizontal" > + + <Button + android:id="@+id/button1" + android:text="Button" /> + + <RadioButton + android:id="@+id/radioButton1" + android:layout_width="150dp" + android:layout_column="0" + android:layout_row="1" + android:text="RadioButton" /> + + <RadioButton + android:id="@+id/radioButton2" + android:text="RadioButton" /> + + <CheckBox + android:id="@+id/checkBox1" + android:text="CheckBox" /> + +</GridLayout> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample11-expected-insertSpacer.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample11-expected-insertSpacer.xml new file mode 100644 index 000000000..d10626a90 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample11-expected-insertSpacer.xml @@ -0,0 +1,59 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright 2010 Google Inc. + + Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0 + + 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. +--> +<GridLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/home_root" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + android:columnCount="3" + android:orientation="horizontal" > + + <Button + android:layout_gravity="fill_horizontal" + android:layout_weight="1" /> + + <Button + android:layout_gravity="fill_horizontal" + android:layout_weight="1" /> + + <Button + android:layout_column="0" + android:layout_gravity="fill_horizontal" + android:layout_weight="1" + android:gravity="center_horizontal" /> + + <Button + android:layout_gravity="fill_horizontal" + android:layout_weight="1" + android:gravity="center_horizontal" /> + + <Button + android:layout_column="0" + android:layout_gravity="fill_horizontal" + android:layout_weight="1" + android:gravity="center_horizontal" /> + + <Button + android:layout_gravity="fill_horizontal" + android:layout_weight="1" + android:gravity="center_horizontal" /> + + <Space + android:layout_column="2" + android:layout_gravity="fill_vertical" + android:layout_row="3" /> + +</GridLayout>
\ No newline at end of file diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample11.info b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample11.info new file mode 100644 index 000000000..560e8a877 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample11.info @@ -0,0 +1,11 @@ +android.widget.LinearLayout [0,50,480,320] <LinearLayout> + android.widget.LinearLayout [0,0,480,270] <LinearLayout> + android.widget.LinearLayout [6,6,474,92] <LinearLayout> + android.widget.Button [0,19,234,67] <Button> + android.widget.Button [234,19,468,67] <Button> + android.widget.LinearLayout [6,92,474,178] <LinearLayout> + android.widget.Button [0,19,234,67] <Button> + android.widget.Button [234,19,468,67] <Button> + android.widget.LinearLayout [6,178,474,264] <LinearLayout> + android.widget.Button [0,19,234,67] <Button> + android.widget.Button [234,19,468,67] <Button> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample11.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample11.xml new file mode 100644 index 000000000..4df91a190 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample11.xml @@ -0,0 +1,92 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright 2010 Google Inc. + + Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0 + + 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. +--> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/home_root" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + android:orientation="vertical" > + + <LinearLayout + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:layout_weight="1" + android:orientation="vertical" + android:padding="6dip" > + + <LinearLayout + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:layout_weight="1" + android:orientation="horizontal" > + + <Button + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:layout_gravity="center_vertical" + android:layout_weight="1" /> + + <Button + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:layout_gravity="center_vertical" + android:layout_weight="1" /> + </LinearLayout> + + <LinearLayout + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:layout_weight="1" + android:orientation="horizontal" > + + <Button + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:layout_gravity="center_vertical" + android:layout_weight="1" + android:gravity="center_horizontal" /> + + <Button + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:layout_gravity="center_vertical" + android:layout_weight="1" + android:gravity="center_horizontal" /> + </LinearLayout> + + <LinearLayout + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:layout_weight="1" + android:orientation="horizontal" > + + <Button + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:layout_gravity="center_vertical" + android:layout_weight="1" + android:gravity="center_horizontal" /> + + <Button + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:layout_gravity="center_vertical" + android:layout_weight="1" + android:gravity="center_horizontal" /> + </LinearLayout> + </LinearLayout> + +</LinearLayout> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample1a-expected-assistant1.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample1a-expected-assistant1.txt new file mode 100644 index 000000000..8eccdfc52 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample1a-expected-assistant1.txt @@ -0,0 +1,3 @@ +Quick assistant in sample1a.xml for <Button android:text="Fir^stButton": +Extract Android String : Initiates the "Extract Android String" refactoring +Extract Style : Initiates the "Extract Style" refactoring diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample1a-expected-assistant2.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample1a-expected-assistant2.txt new file mode 100644 index 000000000..b435ef49c --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample1a-expected-assistant2.txt @@ -0,0 +1,7 @@ +Quick assistant in sample1a.xml for <Bu^tton android:text: +Wrap in Container : Initiates the "Wrap in Container" refactoring +Remove Container : Initiates the "Remove Container" refactoring +Change Widget Type : Initiates the "Change Widget Type" refactoring +Change Layout : Initiates the "Change Layout" refactoring +Extract as Include : Initiates the "Extract as Include" refactoring +Extract Style : Initiates the "Extract Style" refactoring diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample1a-expected-assistant3.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample1a-expected-assistant3.txt new file mode 100644 index 000000000..a7c46c026 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample1a-expected-assistant3.txt @@ -0,0 +1,7 @@ +Quick assistant in sample1a.xml for <Button andr^oid:text="FirstButton": +Wrap in Container : Initiates the "Wrap in Container" refactoring +Remove Container : Initiates the "Remove Container" refactoring +Change Widget Type : Initiates the "Change Widget Type" refactoring +Change Layout : Initiates the "Change Layout" refactoring +Extract as Include : Initiates the "Extract as Include" refactoring +Extract Style : Initiates the "Extract Style" refactoring diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample1a-expected-assistant4.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample1a-expected-assistant4.txt new file mode 100644 index 000000000..30bb00b25 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample1a-expected-assistant4.txt @@ -0,0 +1,3 @@ +Quick assistant in sample1a.xml for android:id="@+id/Linea^rLayout2": +Rename Android Resource : Initiates the "Rename Android Resource" refactoring +Extract Style : Initiates the "Extract Style" refactoring diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample1a-expected-changeLayout1a.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample1a-expected-changeLayout1a.xml new file mode 100644 index 000000000..d03c92535 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample1a-expected-changeLayout1a.xml @@ -0,0 +1,75 @@ +<?xml version="1.0" encoding="utf-8"?> +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/RelativeLayout1" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical" > + + <Button + android:id="@+id/button1" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentLeft="true" + android:layout_alignParentTop="true" + android:text="FirstButton" > + </Button> + + <Button + android:id="@+id/button2" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentLeft="true" + android:layout_below="@+id/button1" + android:layout_marginTop="2dp" + android:text="SecondButton" > + </Button> + + <Button + android:id="@+id/button3" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignBaseline="@+id/button2" + android:layout_alignTop="@+id/button2" + android:layout_toRightOf="@+id/button2" + android:text="ThirdButton" > + </Button> + + <CheckBox + android:id="@+id/checkBox1" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignBaseline="@+id/button2" + android:layout_below="@+id/button1" + android:layout_toRightOf="@+id/button3" + android:text="CheckBox" > + </CheckBox> + + <Button + android:id="@+id/button4" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_alignParentLeft="true" + android:layout_below="@+id/checkBox1" + android:text="FourthButton" > + </Button> + + <Button + android:id="@+id/button5" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentLeft="true" + android:layout_below="@+id/button4" + android:layout_gravity="right" + android:text="FifthButton" > + </Button> + + <Button + android:id="@+id/button6" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentLeft="true" + android:layout_below="@+id/button5" + android:text="Button" > + </Button> + +</RelativeLayout>
\ No newline at end of file diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample1a-expected-changeView1.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample1a-expected-changeView1.xml new file mode 100644 index 000000000..f4a08d023 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample1a-expected-changeView1.xml @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout android:id="@+id/LinearLayout2" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> + <RadioButton android:text="FirstButton" android:id="@+id/RadioButton1" android:layout_width="wrap_content" android:layout_height="wrap_content"></RadioButton> + <LinearLayout android:layout_width="match_parent" android:id="@+id/linearLayout1" android:layout_height="wrap_content"> + <Button android:text="SecondButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/button2"></Button> + <Button android:text="ThirdButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/button3"></Button> + <CheckBox android:id="@+id/checkBox1" android:text="CheckBox" android:layout_width="wrap_content" android:layout_height="wrap_content"></CheckBox> + </LinearLayout> + <Button android:layout_height="wrap_content" android:text="FourthButton" android:id="@+id/button4" android:layout_width="match_parent"></Button> + <LinearLayout android:layout_height="wrap_content" android:id="@+id/linearLayout3" android:layout_width="match_parent"> + <Button android:layout_gravity="right" android:id="@+id/button5" android:text="FifthButton" android:layout_height="wrap_content" android:layout_width="wrap_content"></Button> + </LinearLayout> + <LinearLayout android:layout_height="wrap_content" android:id="@+id/linearLayout4" android:layout_width="match_parent"> + <LinearLayout android:layout_height="match_parent" android:id="@+id/linearLayout5" android:layout_width="wrap_content"> + <LinearLayout android:layout_height="match_parent" android:id="@+id/linearLayout6" android:layout_width="wrap_content"> + <RadioButton android:text="Button" android:id="@+id/RadioButton2" android:layout_width="wrap_content" android:layout_height="wrap_content"></RadioButton> + </LinearLayout> + </LinearLayout> + </LinearLayout> +</LinearLayout> + diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample1a-expected-extract6.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample1a-expected-extract6.diff new file mode 100644 index 000000000..1ae5748e4 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample1a-expected-extract6.diff @@ -0,0 +1,9 @@ +@@ -13 +13 +- <LinearLayout android:layout_height="wrap_content" android:id="@+id/linearLayout4" android:layout_width="match_parent"> +- <LinearLayout android:layout_height="match_parent" android:id="@+id/linearLayout5" android:layout_width="wrap_content"> +- <LinearLayout android:layout_height="match_parent" android:id="@+id/linearLayout6" android:layout_width="wrap_content"> +- <Button android:text="Button" android:id="@+id/button6" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button> +- </LinearLayout> +- </LinearLayout> +- </LinearLayout> ++ <include layout="@layout/newlayout6" android:id="@+id/linearLayout4_ref" android:layout_width="match_parent" android:layout_height="wrap_content"/> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample1a-expected-extract7.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample1a-expected-extract7.diff new file mode 100644 index 000000000..6d18aab26 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample1a-expected-extract7.diff @@ -0,0 +1,84 @@ +@@ -2 +2 +- <LinearLayout android:id="@+id/LinearLayout2" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> +- <Button android:text="FirstButton" android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button> +- <LinearLayout android:layout_width="match_parent" android:id="@+id/linearLayout1" android:layout_height="wrap_content"> +- <Button android:text="SecondButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/button2"></Button> +- <Button android:text="ThirdButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/button3"></Button> +- <CheckBox android:id="@+id/checkBox1" android:text="CheckBox" android:layout_width="wrap_content" android:layout_height="wrap_content"></CheckBox> +- </LinearLayout> +- <Button android:layout_height="wrap_content" android:text="FourthButton" android:id="@+id/button4" android:layout_width="match_parent"></Button> +- <LinearLayout android:layout_height="wrap_content" android:id="@+id/linearLayout3" android:layout_width="match_parent"> +- <Button android:layout_gravity="right" android:id="@+id/button5" android:text="FifthButton" android:layout_height="wrap_content" android:layout_width="wrap_content"></Button> ++ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" ++ android:id="@+id/LinearLayout2" ++ android:layout_width="match_parent" ++ android:layout_height="match_parent" ++ android:orientation="vertical" > ++ ++ <Button ++ android:id="@+id/button1" ++ android:layout_width="wrap_content" ++ android:layout_height="wrap_content" ++ android:text="FirstButton" > ++ </Button> ++ ++ <LinearLayout ++ android:id="@+id/linearLayout1" ++ android:layout_width="match_parent" ++ android:layout_height="wrap_content" > ++ ++ <Button ++ android:id="@+id/button2" ++ android:layout_width="wrap_content" ++ android:layout_height="wrap_content" ++ android:text="SecondButton" > ++ </Button> ++ ++ <Button ++ android:id="@+id/button3" ++ android:layout_width="wrap_content" ++ android:layout_height="wrap_content" ++ android:text="ThirdButton" > ++ </Button> ++ ++ <CheckBox ++ android:id="@+id/checkBox1" ++ android:layout_width="wrap_content" ++ android:layout_height="wrap_content" ++ android:text="CheckBox" > ++ </CheckBox> +@@ -13 +41 +- <LinearLayout android:layout_height="wrap_content" android:id="@+id/linearLayout4" android:layout_width="match_parent"> +- <LinearLayout android:layout_height="match_parent" android:id="@+id/linearLayout5" android:layout_width="wrap_content"> +- <LinearLayout android:layout_height="match_parent" android:id="@+id/linearLayout6" android:layout_width="wrap_content"> +- <Button android:text="Button" android:id="@+id/button6" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button> +- </LinearLayout> +- </LinearLayout> ++ ++ <Button ++ android:id="@+id/button4" ++ android:layout_width="match_parent" ++ android:layout_height="wrap_content" ++ android:text="FourthButton" > ++ </Button> ++ ++ <LinearLayout ++ android:id="@+id/linearLayout3" ++ android:layout_width="match_parent" ++ android:layout_height="wrap_content" > ++ ++ <Button ++ android:id="@+id/button5" ++ android:layout_width="wrap_content" ++ android:layout_height="wrap_content" ++ android:layout_gravity="right" ++ android:text="FifthButton" > ++ </Button> +@@ -20 +62 ++ ++ <include ++ android:id="@+id/linearLayout4_ref" ++ android:layout_width="match_parent" ++ android:layout_height="wrap_content" ++ layout="@layout/newlayout6" /> ++ diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample1a-expected-gridLayout1.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample1a-expected-gridLayout1.xml new file mode 100644 index 000000000..72fe214ce --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample1a-expected-gridLayout1.xml @@ -0,0 +1,61 @@ +<?xml version="1.0" encoding="utf-8"?> +<GridLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/GridLayout1" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:columnCount="4" + android:orientation="horizontal" > + + <Button + android:id="@+id/button1" + android:layout_gravity="left" + android:text="FirstButton" > + </Button> + + <Button + android:id="@+id/button2" + android:layout_column="0" + android:layout_gravity="left" + android:text="SecondButton" > + </Button> + + <Button + android:id="@+id/button3" + android:layout_gravity="left" + android:text="ThirdButton" > + </Button> + + <CheckBox + android:id="@+id/checkBox1" + android:layout_gravity="left" + android:text="CheckBox" > + </CheckBox> + + <Button + android:id="@+id/button4" + android:layout_column="0" + android:layout_columnSpan="3" + android:layout_gravity="fill_horizontal" + android:text="FourthButton" > + </Button> + + <Button + android:id="@+id/button5" + android:layout_column="0" + android:layout_gravity="right" + android:text="FifthButton" > + </Button> + + <Button + android:id="@+id/button6" + android:layout_column="0" + android:layout_gravity="left" + android:text="Button" > + </Button> + + <Space + android:layout_column="3" + android:layout_gravity="fill_vertical" + android:layout_row="5" /> + +</GridLayout>
\ No newline at end of file diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample1a.info b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample1a.info new file mode 100644 index 000000000..20a23b08d --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample1a.info @@ -0,0 +1,13 @@ +android.widget.LinearLayout [0,36,240,320] <LinearLayout> + android.widget.Button [0,0,70,36] <Button> + android.widget.LinearLayout [0,36,240,72] <LinearLayout> + android.widget.Button [0,2,84,38] <Button> + android.widget.Button [84,2,158,38] <Button> + android.widget.CheckBox [158,0,238,36] <CheckBox> + android.widget.Button [0,72,240,108] <Button> + android.widget.LinearLayout [0,108,240,144] <LinearLayout> + android.widget.Button [0,0,71,36] <Button> + android.widget.LinearLayout [0,144,240,180] <LinearLayout> + android.widget.LinearLayout [0,0,49,36] <LinearLayout> + android.widget.LinearLayout [0,0,49,36] <LinearLayout> + android.widget.Button [0,0,49,36] <Button> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample1a.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample1a.xml new file mode 100644 index 000000000..9a9493592 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample1a.xml @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout android:id="@+id/LinearLayout2" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> + <Button android:text="FirstButton" android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button> + <LinearLayout android:layout_width="match_parent" android:id="@+id/linearLayout1" android:layout_height="wrap_content"> + <Button android:text="SecondButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/button2"></Button> + <Button android:text="ThirdButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/button3"></Button> + <CheckBox android:id="@+id/checkBox1" android:text="CheckBox" android:layout_width="wrap_content" android:layout_height="wrap_content"></CheckBox> + </LinearLayout> + <Button android:layout_height="wrap_content" android:text="FourthButton" android:id="@+id/button4" android:layout_width="match_parent"></Button> + <LinearLayout android:layout_height="wrap_content" android:id="@+id/linearLayout3" android:layout_width="match_parent"> + <Button android:layout_gravity="right" android:id="@+id/button5" android:text="FifthButton" android:layout_height="wrap_content" android:layout_width="wrap_content"></Button> + </LinearLayout> + <LinearLayout android:layout_height="wrap_content" android:id="@+id/linearLayout4" android:layout_width="match_parent"> + <LinearLayout android:layout_height="match_parent" android:id="@+id/linearLayout5" android:layout_width="wrap_content"> + <LinearLayout android:layout_height="match_parent" android:id="@+id/linearLayout6" android:layout_width="wrap_content"> + <Button android:text="Button" android:id="@+id/button6" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button> + </LinearLayout> + </LinearLayout> + </LinearLayout> +</LinearLayout> + diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample1b-expected-changeLayout1b.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample1b-expected-changeLayout1b.xml new file mode 100644 index 000000000..d03c92535 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample1b-expected-changeLayout1b.xml @@ -0,0 +1,75 @@ +<?xml version="1.0" encoding="utf-8"?> +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/RelativeLayout1" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical" > + + <Button + android:id="@+id/button1" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentLeft="true" + android:layout_alignParentTop="true" + android:text="FirstButton" > + </Button> + + <Button + android:id="@+id/button2" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentLeft="true" + android:layout_below="@+id/button1" + android:layout_marginTop="2dp" + android:text="SecondButton" > + </Button> + + <Button + android:id="@+id/button3" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignBaseline="@+id/button2" + android:layout_alignTop="@+id/button2" + android:layout_toRightOf="@+id/button2" + android:text="ThirdButton" > + </Button> + + <CheckBox + android:id="@+id/checkBox1" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignBaseline="@+id/button2" + android:layout_below="@+id/button1" + android:layout_toRightOf="@+id/button3" + android:text="CheckBox" > + </CheckBox> + + <Button + android:id="@+id/button4" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_alignParentLeft="true" + android:layout_below="@+id/checkBox1" + android:text="FourthButton" > + </Button> + + <Button + android:id="@+id/button5" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentLeft="true" + android:layout_below="@+id/button4" + android:layout_gravity="right" + android:text="FifthButton" > + </Button> + + <Button + android:id="@+id/button6" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentLeft="true" + android:layout_below="@+id/button5" + android:text="Button" > + </Button> + +</RelativeLayout>
\ No newline at end of file diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample1b.info b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample1b.info new file mode 100644 index 000000000..7807227c3 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample1b.info @@ -0,0 +1,14 @@ +android.widget.LinearLayout [0,36,240,320] <LinearLayout> + android.widget.Button [0,0,70,36] <Button> + android.widget.LinearLayout [0,36,240,72] <LinearLayout> + android.widget.Button [0,2,84,38] <Button> + android.widget.Button [84,2,158,38] <Button> + android.widget.CheckBox [158,0,238,36] <CheckBox> + android.widget.Button [0,72,240,108] <Button> + android.widget.LinearLayout [0,108,240,144] <LinearLayout> + android.widget.Button [0,0,71,36] <Button> + android.widget.LinearLayout [0,144,240,180] <LinearLayout> + android.widget.LinearLayout [0,0,49,36] <LinearLayout> + android.widget.LinearLayout [0,0,49,36] <LinearLayout> + android.widget.Button [0,0,49,36] <Button> + diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample1b.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample1b.xml new file mode 100644 index 000000000..6b800ae77 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample1b.xml @@ -0,0 +1,70 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout + android:id="@+id/LinearLayout2" + xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical"> + <Button + android:text="FirstButton" + android:id="@+id/button1" + android:layout_width="wrap_content" + android:layout_height="wrap_content"></Button> + <LinearLayout + android:layout_width="match_parent" + android:id="@+id/linearLayout1" + android:layout_height="wrap_content"> + <Button + android:text="SecondButton" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:id="@+id/button2"></Button> + <Button + android:text="ThirdButton" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:id="@+id/button3"></Button> + <CheckBox + android:id="@+id/checkBox1" + android:text="CheckBox" + android:layout_width="wrap_content" + android:layout_height="wrap_content"></CheckBox> + </LinearLayout> + <Button + android:layout_height="wrap_content" + android:text="FourthButton" + android:id="@+id/button4" + android:layout_width="match_parent"></Button> + <LinearLayout + android:layout_height="wrap_content" + android:id="@+id/linearLayout3" + android:layout_width="match_parent"> + <Button + android:layout_gravity="right" + android:id="@+id/button5" + android:text="FifthButton" + android:layout_height="wrap_content" + android:layout_width="wrap_content"></Button> + </LinearLayout> + <LinearLayout + android:layout_height="wrap_content" + android:id="@+id/linearLayout4" + android:layout_width="match_parent"> + <LinearLayout + android:layout_height="match_parent" + android:id="@+id/linearLayout5" + android:layout_width="wrap_content"> + <LinearLayout + android:layout_height="match_parent" + android:id="@+id/linearLayout6" + android:layout_width="wrap_content"> + <Button + android:text="Button" + android:id="@+id/button6" + android:layout_width="wrap_content" + android:layout_height="wrap_content"></Button> + </LinearLayout> + </LinearLayout> + </LinearLayout> +</LinearLayout> + diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample2-expected-changeLayout2.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample2-expected-changeLayout2.xml new file mode 100644 index 000000000..06420c483 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample2-expected-changeLayout2.xml @@ -0,0 +1,62 @@ +<?xml version="1.0" encoding="utf-8"?> +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/RelativeLayout1" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical" > + + <Button + android:id="@+id/button1" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentLeft="true" + android:layout_alignParentTop="true" + android:text="Button" > + </Button> + + <Button + android:id="@+id/button2" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentLeft="true" + android:layout_below="@+id/button1" + android:text="Button" > + </Button> + + <Button + android:id="@+id/button3" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_below="@+id/button2" + android:layout_toRightOf="@+id/button2" + android:text="Button" > + </Button> + + <Button + android:id="@+id/button4" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_below="@+id/button3" + android:layout_toRightOf="@+id/button3" + android:text="Button" > + </Button> + + <CheckBox + android:id="@+id/checkBox1" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_below="@+id/button4" + android:layout_toLeftOf="@+id/button4" + android:text="CheckBox" > + </CheckBox> + + <Button + android:id="@+id/button5" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentRight="true" + android:layout_alignTop="@+id/button2" + android:text="Button" > + </Button> + +</RelativeLayout>
\ No newline at end of file diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample2-expected-changeView2.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample2-expected-changeView2.xml new file mode 100644 index 000000000..366c8df70 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample2-expected-changeView2.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> + <Button android:text="Button" android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button> + <RelativeLayout android:layout_height="match_parent" android:id="@+id/relativeLayout1" android:layout_width="match_parent"> + <Button android:layout_width="wrap_content" android:layout_alignParentLeft="true" android:id="@+id/button2" android:layout_height="wrap_content" android:text="Button"></Button> + <ImageButton android:layout_width="wrap_content" android:id="@+id/ImageButton1" android:layout_below="@+id/button2" android:layout_height="wrap_content" android:text="Button" android:layout_toRightOf="@+id/button2"></ImageButton> + <Button android:layout_width="wrap_content" android:id="@+id/button4" android:layout_below="@+id/ImageButton1" android:layout_height="wrap_content" android:text="Button" android:layout_toRightOf="@+id/ImageButton1"></Button> + <CheckBox android:layout_width="wrap_content" android:layout_below="@+id/button4" android:id="@+id/checkBox1" android:layout_height="wrap_content" android:text="CheckBox" android:layout_toLeftOf="@+id/button4"></CheckBox> + <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button" android:id="@+id/ImageButton2" android:layout_alignParentRight="true"></ImageButton> + </RelativeLayout> +</LinearLayout> + + diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample2-expected-extract3.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample2-expected-extract3.xml new file mode 100644 index 000000000..e4ff73166 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample2-expected-extract3.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> + <Button android:text="Button" android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button> + <RelativeLayout android:layout_height="match_parent" android:id="@+id/relativeLayout1" android:layout_width="match_parent"> + <Button android:layout_width="wrap_content" android:layout_alignParentLeft="true" android:id="@+id/button2" android:layout_height="wrap_content" android:text="Button"></Button> + <include layout="@layout/newlayout3" android:id="@+id/button3_ref" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/button2" android:layout_toRightOf="@+id/button2"/> + <Button android:layout_width="wrap_content" android:id="@+id/button4" android:layout_below="@+id/button3_ref" android:layout_height="wrap_content" android:text="Button" android:layout_toRightOf="@+id/button3_ref"></Button> + <CheckBox android:layout_width="wrap_content" android:layout_below="@+id/button4" android:id="@+id/checkBox1" android:layout_height="wrap_content" android:text="CheckBox" android:layout_toLeftOf="@+id/button4"></CheckBox> + <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button" android:id="@+id/button5" android:layout_alignParentRight="true"></Button> + </RelativeLayout> +</LinearLayout> + + diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample2-expected-gridLayout2.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample2-expected-gridLayout2.xml new file mode 100644 index 000000000..8b9056216 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample2-expected-gridLayout2.xml @@ -0,0 +1,67 @@ +<?xml version="1.0" encoding="utf-8"?> +<GridLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/GridLayout1" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:columnCount="6" + android:orientation="horizontal" > + + <Button + android:id="@+id/button1" + android:layout_columnSpan="2" + android:layout_gravity="left" + android:text="Button" > + </Button> + + <Button + android:id="@+id/button2" + android:layout_alignParentLeft="true" + android:layout_column="0" + android:layout_columnSpan="2" + android:layout_gravity="left" + android:text="Button" > + </Button> + + <Button + android:id="@+id/button3" + android:layout_below="@+id/button2" + android:layout_gravity="left" + android:layout_row="2" + android:layout_toRightOf="@+id/button2" + android:text="Button" > + </Button> + + <Button + android:id="@+id/button4" + android:layout_below="@+id/button3" + android:layout_gravity="left" + android:layout_row="3" + android:layout_toRightOf="@+id/button3" + android:text="Button" > + </Button> + + <CheckBox + android:id="@+id/checkBox1" + android:layout_below="@+id/button4" + android:layout_column="1" + android:layout_columnSpan="2" + android:layout_gravity="left" + android:layout_toLeftOf="@+id/button4" + android:text="CheckBox" > + </CheckBox> + + <Button + android:id="@+id/button5" + android:layout_alignParentRight="true" + android:layout_column="4" + android:layout_gravity="left" + android:layout_row="1" + android:text="Button" > + </Button> + + <Space + android:layout_column="5" + android:layout_gravity="fill_vertical" + android:layout_row="5" /> + +</GridLayout>
\ No newline at end of file diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample2.info b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample2.info new file mode 100644 index 000000000..44d3b626d --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample2.info @@ -0,0 +1,9 @@ +android.widget.LinearLayout [0,36,240,320] <LinearLayout> + android.widget.Button [0,0,49,36] <Button> + android.widget.RelativeLayout [0,36,240,284] <RelativeLayout> + android.widget.Button [0,0,49,36] <Button> + android.widget.Button [49,36,98,72] <Button> + android.widget.Button [98,72,147,108] <Button> + android.widget.CheckBox [18,108,98,144] <CheckBox> + android.widget.Button [191,0,240,36] <Button> + diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample2.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample2.xml new file mode 100644 index 000000000..0697c645c --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample2.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> + <Button android:text="Button" android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button> + <RelativeLayout android:layout_height="match_parent" android:id="@+id/relativeLayout1" android:layout_width="match_parent"> + <Button android:layout_width="wrap_content" android:layout_alignParentLeft="true" android:id="@+id/button2" android:layout_height="wrap_content" android:text="Button"></Button> + <Button android:layout_width="wrap_content" android:id="@+id/button3" android:layout_below="@+id/button2" android:layout_height="wrap_content" android:text="Button" android:layout_toRightOf="@+id/button2"></Button> + <Button android:layout_width="wrap_content" android:id="@+id/button4" android:layout_below="@+id/button3" android:layout_height="wrap_content" android:text="Button" android:layout_toRightOf="@+id/button3"></Button> + <CheckBox android:layout_width="wrap_content" android:layout_below="@+id/button4" android:id="@+id/checkBox1" android:layout_height="wrap_content" android:text="CheckBox" android:layout_toLeftOf="@+id/button4"></CheckBox> + <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button" android:id="@+id/button5" android:layout_alignParentRight="true"></Button> + </RelativeLayout> +</LinearLayout> + + diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample3-expected-changeLayout3.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample3-expected-changeLayout3.xml new file mode 100644 index 000000000..268688b83 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample3-expected-changeLayout3.xml @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="utf-8"?> +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/newlinear" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical" > + + <Button + android:id="@+id/button1" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentLeft="true" + android:layout_alignParentTop="true" + android:text="Button" > + </Button> + + <ImageView + android:id="@+id/android_logo" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_above="@+id/button2" + android:layout_alignParentLeft="true" + android:layout_below="@+id/button1" + android:layout_weight="1.0" + android:clickable="false" + android:focusable="false" + android:src="@drawable/android_button" /> + + <Button + android:id="@+id/button2" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentBottom="true" + android:layout_alignParentLeft="true" + android:text="Button" > + </Button> + +</RelativeLayout>
\ No newline at end of file diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample3-expected-extract1.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample3-expected-extract1.xml new file mode 100644 index 000000000..70f576ed6 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample3-expected-extract1.xml @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/newlinear" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> + <Button android:text="Button" android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button> + <ImageView android:id="@+id/android_logo" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/android_button" android:focusable="false" android:clickable="false" android:layout_weight="1.0" /> + <include layout="@layout/newlayout1" android:id="@+id/button2_ref" android:layout_width="wrap_content" android:layout_height="wrap_content"/> +</LinearLayout> + diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample3-expected-extract2.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample3-expected-extract2.xml new file mode 100644 index 000000000..9a30a96b5 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample3-expected-extract2.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/newlinear" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> + <Button android:text="Button" android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button> + <include layout="@layout/newlayout2" android:layout_width="wrap_content" android:layout_height="wrap_content"/> +</LinearLayout> + diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample3-expected-extract4.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample3-expected-extract4.xml new file mode 100644 index 000000000..445f88ac0 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample3-expected-extract4.xml @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/newlinear" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> + <Button android:text="Button" android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button> + <include layout="@layout/newlayout3" android:id="@+id/android_logo_ref" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1.0"/> + <Button android:text="Button" android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button> +</LinearLayout> + diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample3-expected-extract5.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample3-expected-extract5.xml new file mode 100644 index 000000000..8df41ca2e --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample3-expected-extract5.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/newlinear" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> + <include layout="@layout/newlayout3" android:layout_width="wrap_content" android:layout_height="wrap_content"/> + <Button android:text="Button" android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button> +</LinearLayout> + diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample3-expected-wrapIn1.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample3-expected-wrapIn1.xml new file mode 100644 index 000000000..097f87046 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample3-expected-wrapIn1.xml @@ -0,0 +1,36 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/newlinear" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical" > + + <Button + android:id="@+id/button1" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="Button" > + </Button> + + <ImageView + android:id="@+id/android_logo" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_weight="1.0" + android:clickable="false" + android:focusable="false" + android:src="@drawable/android_button" /> + + <LinearLayout + android:layout_width="wrap_content" + android:layout_height="wrap_content" > + + <Button + android:id="@+id/button2" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="Button" > + </Button> + </LinearLayout> + +</LinearLayout>
\ No newline at end of file diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample3-expected-wrapIn2.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample3-expected-wrapIn2.xml new file mode 100644 index 000000000..2921e40e7 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample3-expected-wrapIn2.xml @@ -0,0 +1,36 @@ +<?xml version="1.0" encoding="utf-8"?> +<android.gesture.GestureOverlayView xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" > + + <LinearLayout + android:id="@+id/newlinear" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical" > + + <Button + android:id="@+id/button1" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="Button" > + </Button> + + <ImageView + android:id="@+id/android_logo" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_weight="1.0" + android:clickable="false" + android:focusable="false" + android:src="@drawable/android_button" /> + + <Button + android:id="@+id/button2" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="Button" > + </Button> + </LinearLayout> + +</android.gesture.GestureOverlayView>
\ No newline at end of file diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample3-expected-wrapIn3.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample3-expected-wrapIn3.xml new file mode 100644 index 000000000..6b57216a6 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample3-expected-wrapIn3.xml @@ -0,0 +1,36 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/newlinear" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical" > + + <Button + android:id="@+id/button1" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="Button" > + </Button> + + <LinearLayout + android:layout_width="wrap_content" + android:layout_height="wrap_content" > + + <ImageView + android:id="@+id/android_logo" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_weight="1.0" + android:clickable="false" + android:focusable="false" + android:src="@drawable/android_button" /> + + <Button + android:id="@+id/button2" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="Button" > + </Button> + </LinearLayout> + +</LinearLayout>
\ No newline at end of file diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample3-variation1-expected-extract4.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample3-variation1-expected-extract4.xml new file mode 100644 index 000000000..d616269ab --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample3-variation1-expected-extract4.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/newlinear" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> + <Button android:text="Button" android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button> + <LinearLayout android:id="@+id/newlinear2" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> + <Button android:text="Button" android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button> + <include layout="@layout/newlayout3" android:id="@+id/android_logo_ref" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1.0"/> + </LinearLayout> +</LinearLayout> + diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample3-variation1-expected-extract5.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample3-variation1-expected-extract5.xml new file mode 100644 index 000000000..b37e7bebb --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample3-variation1-expected-extract5.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/newlinear" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> + <Button android:text="Button" android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button> + <LinearLayout android:id="@+id/newlinear2" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> + <include layout="@layout/newlayout3" android:layout_width="wrap_content" android:layout_height="wrap_content"/> + </LinearLayout> +</LinearLayout> + diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample3-variation1.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample3-variation1.xml new file mode 100644 index 000000000..9cf3c434a --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample3-variation1.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/newlinear" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> + <Button android:text="Button" android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button> + <LinearLayout android:id="@+id/newlinear2" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> + <Button android:text="Button" android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button> + <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/android_button" + android:focusable="false" android:clickable="false" android:layout_weight="1.0" android:id="@+id/android_logo" /> + </LinearLayout> +</LinearLayout> + diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample3-variation2-expected-extract4.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample3-variation2-expected-extract4.xml new file mode 100644 index 000000000..40676abd1 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample3-variation2-expected-extract4.xml @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:customprefix="http://schemas.android.com/apk/res/android" customprefix:id="@+id/newlinear" customprefix:orientation="vertical" customprefix:layout_width="match_parent" customprefix:layout_height="match_parent"> + <include layout="@layout/newlayout3" customprefix:id="@+id/android_logo_ref" customprefix:layout_width="wrap_content" customprefix:layout_height="wrap_content" customprefix:layout_weight="1.0"/> + <Button customprefix:text="Button" customprefix:id="@+id/button1" customprefix:layout_width="wrap_content" customprefix:layout_height="wrap_content"></Button> + <Button customprefix:text="Button" customprefix:id="@+id/button2" customprefix:layout_width="wrap_content" customprefix:layout_height="wrap_content"></Button> +</LinearLayout> + diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample3-variation2-expected-extract5.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample3-variation2-expected-extract5.xml new file mode 100644 index 000000000..c51dc3797 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample3-variation2-expected-extract5.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:customprefix="http://schemas.android.com/apk/res/android" customprefix:id="@+id/newlinear" customprefix:orientation="vertical" customprefix:layout_width="match_parent" customprefix:layout_height="match_parent"> + <include layout="@layout/newlayout3" customprefix:layout_width="wrap_content" customprefix:layout_height="wrap_content"/> + <Button customprefix:text="Button" customprefix:id="@+id/button2" customprefix:layout_width="wrap_content" customprefix:layout_height="wrap_content"></Button> +</LinearLayout> + diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample3-variation2.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample3-variation2.xml new file mode 100644 index 000000000..48d479024 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample3-variation2.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:customprefix="http://schemas.android.com/apk/res/android" customprefix:id="@+id/newlinear" customprefix:orientation="vertical" customprefix:layout_width="match_parent" customprefix:layout_height="match_parent"> + <ImageView customprefix:id="@+id/android_logo" customprefix:layout_width="wrap_content" + customprefix:layout_height="wrap_content" customprefix:src="@drawable/android_button" customprefix:focusable="false" customprefix:clickable="false" customprefix:layout_weight="1.0" /> + <Button customprefix:text="Button" customprefix:id="@+id/button1" customprefix:layout_width="wrap_content" customprefix:layout_height="wrap_content"></Button> + <Button customprefix:text="Button" customprefix:id="@+id/button2" customprefix:layout_width="wrap_content" customprefix:layout_height="wrap_content"></Button> +</LinearLayout> + diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample3.info b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample3.info new file mode 100644 index 000000000..ef3324eb4 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample3.info @@ -0,0 +1,5 @@ +android.widget.LinearLayout [0,36,240,320] <LinearLayout> + android.widget.Button [0,0,49,36] <Button> + android.widget.ImageView [0,36,128,248] <ImageView> + android.widget.Button [0,248,49,284] <Button> + diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample3.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample3.xml new file mode 100644 index 000000000..ddd136ce8 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample3.xml @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/newlinear" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> + <Button android:text="Button" android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button> + <ImageView android:id="@+id/android_logo" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/android_button" android:focusable="false" android:clickable="false" android:layout_weight="1.0" /> + <Button android:text="Button" android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button> +</LinearLayout> + diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample4-expected-changeLayout4.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample4-expected-changeLayout4.xml new file mode 100644 index 000000000..6e5552950 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample4-expected-changeLayout4.xml @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="utf-8"?> +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/RelativeLayout1" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical" > + + <CheckBox + android:id="@+id/checkBox1" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentLeft="true" + android:layout_alignParentTop="true" + android:text="CheckBox" > + </CheckBox> + + <Button + android:id="@+id/button5" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentRight="true" + android:layout_below="@+id/checkBox1" + android:text="Button" > + </Button> + +</RelativeLayout>
\ No newline at end of file diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample4.info b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample4.info new file mode 100644 index 000000000..605c17793 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample4.info @@ -0,0 +1,5 @@ +android.widget.LinearLayout [0,36,240,320] <LinearLayout> + android.widget.CheckBox [0,0,80,36] <CheckBox> + android.widget.RelativeLayout [0,36,240,284] <RelativeLayout> + android.widget.Button [191,0,240,36] <Button> + diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample4.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample4.xml new file mode 100644 index 000000000..a56f27294 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample4.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> + <CheckBox android:text="CheckBox" android:id="@+id/checkBox1" android:layout_width="wrap_content" android:layout_height="wrap_content"></CheckBox> + <RelativeLayout android:layout_height="match_parent" android:id="@+id/relativeLayout1" android:layout_width="match_parent"> + <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button" android:id="@+id/button5" android:layout_alignParentRight="true"></Button> + </RelativeLayout> +</LinearLayout> + diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample5-expected-changeLayout5.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample5-expected-changeLayout5.xml new file mode 100644 index 000000000..06b236dfb --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample5-expected-changeLayout5.xml @@ -0,0 +1,70 @@ +<?xml version="1.0" encoding="utf-8"?> +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/RelativeLayout1" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical" > + + <Button + android:id="@+id/button1" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentTop="true" + android:layout_centerHorizontal="true" + android:layout_gravity="center_horizontal" + android:text="Button" > + </Button> + + <Button + android:id="@+id/button2" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_below="@+id/button1" + android:layout_centerHorizontal="true" + android:layout_gravity="center" + android:text="Button" > + </Button> + + <Button + android:id="@+id/button3" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentRight="true" + android:layout_below="@+id/button2" + android:layout_gravity="right" + android:text="Button" > + </Button> + + <Button + android:id="@+id/button4" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentLeft="true" + android:layout_below="@+id/button3" + android:layout_gravity="center" + android:layout_marginTop="70dp" + android:text="Button" > + </Button> + + <Button + android:id="@+id/button5" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignBaseline="@+id/button4" + android:layout_alignTop="@+id/button4" + android:layout_gravity="center_vertical" + android:layout_toRightOf="@+id/button4" + android:text="Button" > + </Button> + + <Button + android:id="@+id/button6" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentBottom="true" + android:layout_gravity="bottom" + android:layout_toRightOf="@+id/button5" + android:text="Button" > + </Button> + +</RelativeLayout>
\ No newline at end of file diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample5-expected-gridLayout5.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample5-expected-gridLayout5.xml new file mode 100644 index 000000000..dd9f18cf2 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample5-expected-gridLayout5.xml @@ -0,0 +1,51 @@ +<?xml version="1.0" encoding="utf-8"?> +<GridLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/GridLayout1" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:columnCount="4" + android:orientation="horizontal" > + + <Button + android:id="@+id/button1" + android:layout_columnSpan="2" + android:layout_gravity="center_horizontal" + android:text="Button" > + </Button> + + <Button + android:id="@+id/button2" + android:layout_columnSpan="2" + android:layout_gravity="center" + android:layout_row="1" + android:text="Button" > + </Button> + + <Button + android:id="@+id/button3" + android:layout_column="2" + android:layout_columnSpan="2" + android:layout_gravity="right" + android:text="Button" > + </Button> + + <Button + android:id="@+id/button4" + android:layout_gravity="center" + android:text="Button" > + </Button> + + <Button + android:id="@+id/button5" + android:layout_columnSpan="2" + android:layout_gravity="center_vertical" + android:text="Button" > + </Button> + + <Button + android:id="@+id/button6" + android:layout_gravity="bottom" + android:text="Button" > + </Button> + +</GridLayout>
\ No newline at end of file diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample5.info b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample5.info new file mode 100644 index 000000000..fce532ecd --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample5.info @@ -0,0 +1,9 @@ +android.widget.LinearLayout [0,36,240,320] <LinearLayout> + android.widget.Button [95,0,144,36] <Button> + android.widget.Button [95,36,144,72] <Button> + android.widget.Button [191,72,240,108] <Button> + android.widget.LinearLayout [0,108,240,284] <LinearLayout> + android.widget.Button [0,70,49,106] <Button> + android.widget.Button [49,70,98,106] <Button> + android.widget.Button [98,140,147,176] <Button> + diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample5.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample5.xml new file mode 100644 index 000000000..afc19388d --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample5.xml @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> + <Button android:text="Button" android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal"></Button> + <Button android:text="Button" android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center"></Button> + <Button android:text="Button" android:id="@+id/button3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="right"></Button> + <LinearLayout android:id="@+id/linearLayout1" android:layout_width="match_parent" android:layout_height="match_parent"> + <Button android:layout_height="wrap_content" android:layout_gravity="center" android:text="Button" android:id="@+id/button4" android:layout_width="wrap_content"></Button> + <Button android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:text="Button" android:id="@+id/button5" android:layout_width="wrap_content"></Button> + <Button android:layout_height="wrap_content" android:text="Button" android:id="@+id/button6" android:layout_width="wrap_content" android:layout_gravity="bottom"></Button> + </LinearLayout> +</LinearLayout> + diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample6-expected-changeLayout6.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample6-expected-changeLayout6.xml new file mode 100644 index 000000000..a91ad1e7b --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample6-expected-changeLayout6.xml @@ -0,0 +1,37 @@ +<?xml version="1.0" encoding="utf-8"?> +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/RelativeLayout1" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:baselineAligned="true" > + + <Button + android:id="@+id/button1" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignBaseline="@+id/button2" + android:layout_alignParentLeft="true" + android:layout_alignParentTop="true" + android:text="Button" > + </Button> + + <RadioButton + android:id="@+id/radioButton1" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignBaseline="@+id/button2" + android:layout_alignParentTop="true" + android:layout_toRightOf="@+id/button1" + android:text="RadioButton" > + </RadioButton> + + <Button + android:id="@+id/button2" + android:layout_width="wrap_content" + android:layout_height="150dip" + android:layout_alignParentTop="true" + android:layout_toRightOf="@+id/radioButton1" + android:text="Button" > + </Button> + +</RelativeLayout>
\ No newline at end of file diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample6.info b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample6.info new file mode 100644 index 000000000..7a7a44ab5 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample6.info @@ -0,0 +1,5 @@ +android.widget.LinearLayout [0,36,240,320] <LinearLayout> + android.widget.Button [0,38,49,74] <Button> + android.widget.RadioButton [49,36,143,72] <RadioButton> + android.widget.Button [143,0,192,113] <Button> + diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample6.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample6.xml new file mode 100644 index 000000000..5cdc82493 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample6.xml @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/LinearLayout1" android:layout_width="match_parent" android:layout_height="match_parent" android:baselineAligned="true"> + <Button android:text="Button" android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button> + <RadioButton android:text="RadioButton" android:id="@+id/radioButton1" android:layout_width="wrap_content" android:layout_height="wrap_content"></RadioButton> + <Button android:layout_width="wrap_content" android:id="@+id/button2" android:text="Button" android:layout_height="150dip"></Button> +</LinearLayout> + diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample7-expected-extract6.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample7-expected-extract6.diff new file mode 100644 index 000000000..8a01599a6 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample7-expected-extract6.diff @@ -0,0 +1,10 @@ +@@ -4 +4 +- <LinearLayout android:layout_height="wrap_content" android:id="@+id/linearLayout4" android:layout_width="match_parent"> +- <LinearLayout android:layout_height="match_parent" android:id="@+id/linearLayout5" android:layout_width="wrap_content"> +- <LinearLayout android:layout_height="match_parent" android:id="@+id/linearLayout6" android:layout_width="wrap_content"> +- <!-- Comment --> +- <Button android:text="Button" android:id="@+id/button6" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button> +- </LinearLayout> +- </LinearLayout> +- </LinearLayout> ++ <include layout="@layout/newlayout6" android:id="@+id/linearLayout4_ref" android:layout_width="match_parent" android:layout_height="wrap_content"/> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample7-expected-extract7.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample7-expected-extract7.diff new file mode 100644 index 000000000..3de135d77 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample7-expected-extract7.diff @@ -0,0 +1,69 @@ +@@ -2 +2 +- <LinearLayout android:id="@+id/LinearLayout2" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> +- <Button android:text="FirstButton" android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button> +- <LinearLayout android:layout_height="wrap_content" android:id="@+id/linearLayout4" android:layout_width="match_parent"> +- <LinearLayout android:layout_height="match_parent" android:id="@+id/linearLayout5" android:layout_width="wrap_content"> +- <LinearLayout android:layout_height="match_parent" android:id="@+id/linearLayout6" android:layout_width="wrap_content"> +- <!-- Comment --> +- <Button android:text="Button" android:id="@+id/button6" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button> +- </LinearLayout> +- </LinearLayout> +- </LinearLayout> +- <LinearLayout android:layout_width="match_parent" android:id="@+id/linearLayout9" android:layout_height="wrap_content"> +- <Button android:text="SecondButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/button2"></Button> +- <Button android:text="ThirdButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/button3"></Button> +- <CheckBox android:id="@+id/checkBox1" android:text="CheckBox" android:layout_width="wrap_content" android:layout_height="wrap_content"></CheckBox> ++ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" ++ android:id="@+id/LinearLayout2" ++ android:layout_width="match_parent" ++ android:layout_height="match_parent" ++ android:orientation="vertical" > ++ ++ <Button ++ android:id="@+id/button1" ++ android:layout_width="wrap_content" ++ android:layout_height="wrap_content" ++ android:text="FirstButton" > ++ </Button> ++ ++ <include ++ android:id="@+id/linearLayout4_ref" ++ android:layout_width="match_parent" ++ android:layout_height="wrap_content" ++ layout="@layout/newlayout6" /> ++ ++ <LinearLayout ++ android:id="@+id/linearLayout9" ++ android:layout_width="match_parent" ++ android:layout_height="wrap_content" > ++ ++ <Button ++ android:id="@+id/button2" ++ android:layout_width="wrap_content" ++ android:layout_height="wrap_content" ++ android:text="SecondButton" > ++ </Button> ++ ++ <Button ++ android:id="@+id/button3" ++ android:layout_width="wrap_content" ++ android:layout_height="wrap_content" ++ android:text="ThirdButton" > ++ </Button> ++ ++ <CheckBox ++ android:id="@+id/checkBox1" ++ android:layout_width="wrap_content" ++ android:layout_height="wrap_content" ++ android:text="CheckBox" > ++ </CheckBox> +@@ -17 +47 +- <Button android:layout_height="wrap_content" android:text="FourthButton" android:id="@+id/button4" android:layout_width="match_parent"></Button> ++ ++ <Button ++ android:id="@+id/button4" ++ android:layout_width="match_parent" ++ android:layout_height="wrap_content" ++ android:text="FourthButton" > ++ </Button> ++ diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample7.info b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample7.info new file mode 100644 index 000000000..134234c44 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample7.info @@ -0,0 +1,11 @@ +android.widget.LinearLayout [0,0,240,320] <LinearLayout> + android.widget.Button [0,0,101,36] <Button> + android.widget.LinearLayout [0,36,240,72] <LinearLayout> + android.widget.LinearLayout [0,0,73,36] <LinearLayout> + android.widget.LinearLayout [0,0,73,36] <LinearLayout> + android.widget.Button [0,0,73,36] <Button> + android.widget.LinearLayout [0,72,240,192] <LinearLayout> + android.widget.Button [0,0,117,36] <Button> + android.widget.Button [117,0,223,36] <Button> + android.widget.CheckBox [223,10,240,130] <CheckBox> + android.widget.Button [0,192,240,228] <Button> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample7.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample7.xml new file mode 100644 index 000000000..0445bbf8f --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample7.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout android:id="@+id/LinearLayout2" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> + <Button android:text="FirstButton" android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button> + <LinearLayout android:layout_height="wrap_content" android:id="@+id/linearLayout4" android:layout_width="match_parent"> + <LinearLayout android:layout_height="match_parent" android:id="@+id/linearLayout5" android:layout_width="wrap_content"> + <LinearLayout android:layout_height="match_parent" android:id="@+id/linearLayout6" android:layout_width="wrap_content"> + <!-- Comment --> + <Button android:text="Button" android:id="@+id/button6" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button> + </LinearLayout> + </LinearLayout> + </LinearLayout> + <LinearLayout android:layout_width="match_parent" android:id="@+id/linearLayout9" android:layout_height="wrap_content"> + <Button android:text="SecondButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/button2"></Button> + <Button android:text="ThirdButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/button3"></Button> + <CheckBox android:id="@+id/checkBox1" android:text="CheckBox" android:layout_width="wrap_content" android:layout_height="wrap_content"></CheckBox> + </LinearLayout> + <Button android:layout_height="wrap_content" android:text="FourthButton" android:id="@+id/button4" android:layout_width="match_parent"></Button> +</LinearLayout> + diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample8-expected-extract6.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample8-expected-extract6.diff new file mode 100644 index 000000000..ea3afc2e3 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample8-expected-extract6.diff @@ -0,0 +1,15 @@ +@@ -10 +10 +- <LinearLayout android:layout_height="wrap_content" +- android:id="@+id/linearLayout4" android:layout_width="match_parent"> +- <LinearLayout android:layout_height="match_parent" +- android:layout_width="wrap_content" android:id="@+id/linearLayout5"> +- <LinearLayout android:layout_height="match_parent" +- android:id="@+id/linearLayout6" +- android:layout_width="wrap_content"> +- <Button android:text="Button" android:id="@+id/button6" +- android:layout_width="wrap_content" +- android:layout_height="wrap_content"></Button> +- </LinearLayout> +- </LinearLayout> +- </LinearLayout> ++ <include layout="@layout/newlayout6" android:id="@+id/linearLayout4_ref" android:layout_width="match_parent" android:layout_height="wrap_content"/> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample8-expected-extract7.diff b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample8-expected-extract7.diff new file mode 100644 index 000000000..8228b597e --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample8-expected-extract7.diff @@ -0,0 +1,85 @@ +@@ -2 +2 +- <LinearLayout android:id="@+id/LinearLayout2" +- xmlns:android="http://schemas.android.com/apk/res/android" +- android:layout_width="match_parent" android:layout_height="match_parent" +- android:orientation="vertical"> +- <Button android:text="FirstButton" android:id="@+id/button1" +- android:layout_width="wrap_content" android:layout_height="wrap_content"></Button> +- <FrameLayout android:id="@+id/outer" +- android:layout_width="match_parent" android:layout_height="wrap_content"> +- <LinearLayout android:layout_height="wrap_content" +- android:id="@+id/linearLayout4" android:layout_width="match_parent"> +- <LinearLayout android:layout_height="match_parent" +- android:layout_width="wrap_content" android:id="@+id/linearLayout5"> +- <LinearLayout android:layout_height="match_parent" +- android:id="@+id/linearLayout6" +- android:layout_width="wrap_content"> +- <Button android:text="Button" android:id="@+id/button6" +- android:layout_width="wrap_content" +- android:layout_height="wrap_content"></Button> +- </LinearLayout> +- </LinearLayout> +- </LinearLayout> ++ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" ++ android:id="@+id/LinearLayout2" ++ android:layout_width="match_parent" ++ android:layout_height="match_parent" ++ android:orientation="vertical" > ++ ++ <Button ++ android:id="@+id/button1" ++ android:layout_width="wrap_content" ++ android:layout_height="wrap_content" ++ android:text="FirstButton" > ++ </Button> ++ ++ <FrameLayout ++ android:id="@+id/outer" ++ android:layout_width="match_parent" ++ android:layout_height="wrap_content" > ++ ++ <include ++ android:id="@+id/linearLayout4_ref" ++ android:layout_width="match_parent" ++ android:layout_height="wrap_content" ++ layout="@layout/newlayout6" /> +@@ -24 +26 +- <FrameLayout android:id="@+id/outer" +- android:layout_width="match_parent" android:layout_height="wrap_content"> +- <LinearLayout android:layout_height="wrap_content" +- android:id="@+id/linearLayout4" android:layout_width="match_parent"> +- <LinearLayout android:layout_height="match_parent" +- android:layout_width="wrap_content" android:id="@+id/linearLayout5"> +- <LinearLayout android:layout_height="match_parent" ++ ++ <FrameLayout ++ android:id="@+id/outer" ++ android:layout_width="match_parent" ++ android:layout_height="wrap_content" > ++ ++ <LinearLayout ++ android:id="@+id/linearLayout4" ++ android:layout_width="match_parent" ++ android:layout_height="wrap_content" > ++ ++ <LinearLayout ++ android:id="@+id/linearLayout5" ++ android:layout_width="wrap_content" ++ android:layout_height="match_parent" > ++ ++ <LinearLayout +@@ -32 +44 +- android:layout_width="wrap_content"> +- <Button android:text="Button" android:id="@+id/button6" ++ android:layout_width="wrap_content" ++ android:layout_height="match_parent" > ++ ++ <Button ++ android:id="@+id/button6" +@@ -35 +50 +- android:layout_height="wrap_content"></Button> ++ android:layout_height="wrap_content" ++ android:text="Button" > ++ </Button> +@@ -40 +57 ++ diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample8.info b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample8.info new file mode 100644 index 000000000..ca294ba10 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample8.info @@ -0,0 +1,12 @@ +android.widget.LinearLayout [0,0,240,320] <LinearLayout> + android.widget.Button [0,0,101,36] <Button> + android.widget.FrameLayout [0,36,240,72] <FrameLayout> + android.widget.LinearLayout [0,0,240,36] <LinearLayout> + android.widget.LinearLayout [0,0,73,36] <LinearLayout> + android.widget.LinearLayout [0,0,73,36] <LinearLayout> + android.widget.Button [0,0,73,36] <Button> + android.widget.FrameLayout [0,72,240,108] <FrameLayout> + android.widget.LinearLayout [0,0,240,36] <LinearLayout> + android.widget.LinearLayout [0,0,73,36] <LinearLayout> + android.widget.LinearLayout [0,0,73,36] <LinearLayout> + android.widget.Button [0,0,73,36] <Button> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample8.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample8.xml new file mode 100644 index 000000000..c7984692e --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample8.xml @@ -0,0 +1,40 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout android:id="@+id/LinearLayout2" + xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" android:layout_height="match_parent" + android:orientation="vertical"> + <Button android:text="FirstButton" android:id="@+id/button1" + android:layout_width="wrap_content" android:layout_height="wrap_content"></Button> + <FrameLayout android:id="@+id/outer" + android:layout_width="match_parent" android:layout_height="wrap_content"> + <LinearLayout android:layout_height="wrap_content" + android:id="@+id/linearLayout4" android:layout_width="match_parent"> + <LinearLayout android:layout_height="match_parent" + android:layout_width="wrap_content" android:id="@+id/linearLayout5"> + <LinearLayout android:layout_height="match_parent" + android:id="@+id/linearLayout6" + android:layout_width="wrap_content"> + <Button android:text="Button" android:id="@+id/button6" + android:layout_width="wrap_content" + android:layout_height="wrap_content"></Button> + </LinearLayout> + </LinearLayout> + </LinearLayout> + </FrameLayout> + <FrameLayout android:id="@+id/outer" + android:layout_width="match_parent" android:layout_height="wrap_content"> + <LinearLayout android:layout_height="wrap_content" + android:id="@+id/linearLayout4" android:layout_width="match_parent"> + <LinearLayout android:layout_height="match_parent" + android:layout_width="wrap_content" android:id="@+id/linearLayout5"> + <LinearLayout android:layout_height="match_parent" + android:id="@+id/linearLayout6" + android:layout_width="wrap_content"> + <Button android:text="Button" android:id="@+id/button6" + android:layout_width="wrap_content" + android:layout_height="wrap_content"></Button> + </LinearLayout> + </LinearLayout> + </LinearLayout> + </FrameLayout> +</LinearLayout> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample9-expected-convertToGrid.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample9-expected-convertToGrid.xml new file mode 100644 index 000000000..03ffac714 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample9-expected-convertToGrid.xml @@ -0,0 +1,37 @@ +<?xml version="1.0" encoding="utf-8"?> +<GridLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/GridLayout1" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:columnCount="3" + android:orientation="horizontal" > + + <Button + android:id="@+id/button1" + android:layout_gravity="left" + android:text="Button" /> + + <RadioButton + android:id="@+id/radioButton1" + android:layout_width="150dp" + android:layout_column="0" + android:layout_gravity="left" + android:text="RadioButton" /> + + <RadioButton + android:id="@+id/radioButton2" + android:layout_gravity="left" + android:text="RadioButton" /> + + <CheckBox + android:id="@+id/checkBox1" + android:layout_column="0" + android:layout_gravity="left" + android:text="CheckBox" /> + + <Space + android:layout_column="2" + android:layout_gravity="fill_vertical" + android:layout_row="3" /> + +</GridLayout>
\ No newline at end of file diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample9.info b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample9.info new file mode 100644 index 000000000..3085ff074 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample9.info @@ -0,0 +1,6 @@ +android.widget.LinearLayout [0,73,320,480] <LinearLayout> + android.widget.Button [0,0,79,48] <Button> + android.widget.LinearLayout [0,48,320,86] <LinearLayout> + android.widget.RadioButton [0,0,150,38] <RadioButton> + android.widget.RadioButton [150,0,273,38] <RadioButton> + android.widget.CheckBox [0,86,107,124] <CheckBox> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample9.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample9.xml new file mode 100644 index 000000000..13068e763 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/sample9.xml @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/LinearLayout1" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical" > + + <Button + android:id="@+id/button1" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="Button" /> + + <LinearLayout + android:id="@+id/linearLayout2" + android:layout_width="match_parent" + android:layout_height="wrap_content" > + + <RadioButton + android:id="@+id/radioButton1" + android:layout_width="150dp" + android:layout_height="wrap_content" + android:text="RadioButton" /> + + <RadioButton + android:id="@+id/radioButton2" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="RadioButton" /> + + </LinearLayout> + + <CheckBox + android:id="@+id/checkBox1" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="CheckBox" /> + +</LinearLayout> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/unwrap-expected-unwrap1.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/unwrap-expected-unwrap1.xml new file mode 100644 index 000000000..e5aba11bb --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/unwrap-expected-unwrap1.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/linear" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:orientation="vertical" > + + <TextView + android:id="@+id/text" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:text="@string/hello" /> + + <Button + android:id="@+id/button" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:text="@string/hello" /> + +</LinearLayout>
\ No newline at end of file diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/unwrap-expected-unwrap2.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/unwrap-expected-unwrap2.xml new file mode 100644 index 000000000..e5aba11bb --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/unwrap-expected-unwrap2.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/linear" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:orientation="vertical" > + + <TextView + android:id="@+id/text" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:text="@string/hello" /> + + <Button + android:id="@+id/button" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:text="@string/hello" /> + +</LinearLayout>
\ No newline at end of file diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/unwrap-expected-unwrap3.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/unwrap-expected-unwrap3.xml new file mode 100644 index 000000000..348b2bc81 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/unwrap-expected-unwrap3.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="utf-8"?> +<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/frame" + android:layout_width="fill_parent" + android:layout_height="wrap_content" > + + <TextView + android:id="@+id/text" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:text="@string/hello" /> + + <Button + android:id="@+id/button" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:text="@string/hello" /> + +</FrameLayout>
\ No newline at end of file diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/unwrap.info b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/unwrap.info new file mode 100644 index 000000000..c5461b399 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/unwrap.info @@ -0,0 +1,4 @@ +android.widget.LinearLayout [0,56,1280,104] <LinearLayout> + android.widget.FrameLayout [0,0,1280,48] <FrameLayout> + android.widget.TextView [0,0,1280,17] <TextView> + android.widget.Button [0,0,1280,48] <Button> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/unwrap.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/unwrap.xml new file mode 100644 index 000000000..db94dc358 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/unwrap.xml @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/linear" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:orientation="vertical" > + + <FrameLayout + android:id="@+id/frame" + android:layout_width="fill_parent" + android:layout_height="wrap_content" > + + <TextView + android:id="@+id/text" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:text="@string/hello" /> + + <Button + android:id="@+id/button" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:text="@string/hello" /> + </FrameLayout> + +</LinearLayout> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/manifest/ManifestInfoTest.java b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/manifest/ManifestInfoTest.java new file mode 100644 index 000000000..43f9d681f --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/manifest/ManifestInfoTest.java @@ -0,0 +1,424 @@ +/* + * 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.manifest; + +import static com.android.resources.ScreenSize.LARGE; +import static com.android.resources.ScreenSize.NORMAL; +import static com.android.resources.ScreenSize.XLARGE; + +import com.android.annotations.NonNull; +import com.android.ide.eclipse.adt.internal.editors.layout.refactoring.AdtProjectTest; +import com.android.ide.eclipse.adt.internal.editors.manifest.ManifestInfo.ActivityAttributes; +import com.android.ide.eclipse.adt.internal.resources.ResourceHelper; +import com.android.sdklib.AndroidVersion; +import com.android.sdklib.BuildToolInfo; +import com.android.sdklib.IAndroidTarget; +import com.android.sdklib.ISystemImage; +import com.android.sdklib.repository.descriptors.IdDisplay; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.runtime.NullProgressMonitor; + +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +@SuppressWarnings("javadoc") +public class ManifestInfoTest extends AdtProjectTest { + @Override + protected boolean testCaseNeedsUniqueProject() { + return true; + } + + public void testGetActivityThemes1() throws Exception { + ManifestInfo info = getManifestInfo( + "<manifest xmlns:android='http://schemas.android.com/apk/res/android'\n" + + " package='com.android.unittest'>\n" + + " <uses-sdk android:minSdkVersion='3' android:targetSdkVersion='4'/>\n" + + "</manifest>\n"); + Map<String, ActivityAttributes> map = info.getActivityAttributesMap(); + assertEquals(map.toString(), 0, map.size()); + assertEquals("com.android.unittest", info.getPackage()); + assertEquals("Theme", ResourceHelper.styleToTheme(info.getDefaultTheme(null, NORMAL))); + assertEquals("@android:style/Theme", info.getDefaultTheme(null, null)); + assertEquals("Theme", ResourceHelper.styleToTheme(info.getDefaultTheme(null, XLARGE))); + } + + public void testGetActivityThemes2() throws Exception { + ManifestInfo info = getManifestInfo( + "<manifest xmlns:android='http://schemas.android.com/apk/res/android'\n" + + " package='com.android.unittest'>\n" + + " <uses-sdk android:minSdkVersion='3' android:targetSdkVersion='11'/>\n" + + "</manifest>\n"); + Map<String, ActivityAttributes> map = info.getActivityAttributesMap(); + assertEquals(map.toString(), 0, map.size()); + assertEquals("com.android.unittest", info.getPackage()); + assertEquals("Theme.Holo", ResourceHelper.styleToTheme(info.getDefaultTheme(null, + XLARGE))); + assertEquals("Theme", ResourceHelper.styleToTheme(info.getDefaultTheme(null, LARGE))); + } + + public void testGetActivityThemes3() throws Exception { + ManifestInfo info = getManifestInfo( + "<manifest xmlns:android='http://schemas.android.com/apk/res/android'\n" + + " package='com.android.unittest'>\n" + + " <uses-sdk android:minSdkVersion='11'/>\n" + + "</manifest>\n"); + Map<String, ActivityAttributes> map = info.getActivityAttributesMap(); + assertEquals(map.toString(), 0, map.size()); + assertEquals("com.android.unittest", info.getPackage()); + assertEquals("Theme.Holo", ResourceHelper.styleToTheme(info.getDefaultTheme(null, + XLARGE))); + assertEquals("Theme", ResourceHelper.styleToTheme(info.getDefaultTheme(null, NORMAL))); + } + + public void testGetActivityThemes4() throws Exception { + ManifestInfo info = getManifestInfo( + "<manifest xmlns:android='http://schemas.android.com/apk/res/android'\n" + + " package='com.android.unittest'>\n" + + " <application\n" + + " android:label='@string/app_name'\n" + + " android:name='.app.TestApp' android:icon='@drawable/app_icon'>\n" + + "\n" + + " <activity\n" + + " android:name='.prefs.PrefsActivity'\n" + + " android:label='@string/prefs_title' />\n" + + "\n" + + " <activity\n" + + " android:name='.app.IntroActivity'\n" + + " android:label='@string/intro_title'\n" + + " android:theme='@android:style/Theme.Dialog' />\n" + + " </application>\n" + + " <uses-sdk android:minSdkVersion='3' android:targetSdkVersion='4'/>\n" + + "</manifest>\n" + + "" + ); + assertEquals("com.android.unittest", info.getPackage()); + assertEquals("Theme", ResourceHelper.styleToTheme(info.getDefaultTheme(null, XLARGE))); + + Map<String, ActivityAttributes> map = info.getActivityAttributesMap(); + assertEquals(map.toString(), 2, map.size()); + assertNull(map.get("com.android.unittest.prefs.PrefsActivity").getTheme()); + assertEquals("@android:style/Theme.Dialog", + map.get("com.android.unittest.app.IntroActivity").getTheme()); + } + + public void testGetActivityThemes5() throws Exception { + ManifestInfo info = getManifestInfo( + "<manifest xmlns:android='http://schemas.android.com/apk/res/android'\n" + + " package='com.android.unittest'>\n" + + " <application\n" + + " android:label='@string/app_name'\n" + + " android:theme='@style/NoBackground'\n" + + " android:name='.app.TestApp' android:icon='@drawable/app_icon'>\n" + + "\n" + + " <activity\n" + + " android:name='.prefs.PrefsActivity'\n" + + " android:label='@string/prefs_title' />\n" + + "\n" + + " <activity\n" + + " android:name='.app.IntroActivity'\n" + + " android:label='@string/intro_title'\n" + + " android:theme='@android:style/Theme.Dialog' />\n" + + " </application>\n" + + " <uses-sdk android:minSdkVersion='3' android:targetSdkVersion='4'/>\n" + + "</manifest>\n" + + "" + ); + + assertEquals("@style/NoBackground", info.getDefaultTheme(null, XLARGE)); + assertEquals("@style/NoBackground", info.getDefaultTheme(null, NORMAL)); + assertEquals("NoBackground", ResourceHelper.styleToTheme(info.getDefaultTheme(null, + NORMAL))); + + Map<String, ActivityAttributes> map = info.getActivityAttributesMap(); + assertEquals(map.toString(), 2, map.size()); + assertNull(map.get("com.android.unittest.prefs.PrefsActivity").getTheme()); + assertEquals("@android:style/Theme.Dialog", + map.get("com.android.unittest.app.IntroActivity").getTheme()); + } + + public void testGetActivityThemes6() throws Exception { + // Ensures that when the *rendering* target is less than version 11, we don't + // use Holo even though the manifest SDK version calls for it. + ManifestInfo info = getManifestInfo( + "<manifest xmlns:android='http://schemas.android.com/apk/res/android'\n" + + " package='com.android.unittest'>\n" + + " <uses-sdk android:minSdkVersion='3' android:targetSdkVersion='11'/>\n" + + "</manifest>\n"); + Map<String, ActivityAttributes> map = info.getActivityAttributesMap(); + assertEquals(map.toString(), 0, map.size()); + assertEquals("com.android.unittest", info.getPackage()); + assertEquals("Theme.Holo", ResourceHelper.styleToTheme(info.getDefaultTheme(null, + XLARGE))); + + // Here's the check + IAndroidTarget olderVersion = new TestAndroidTarget(4); + assertEquals("Theme", ResourceHelper.styleToTheme(info.getDefaultTheme(olderVersion, + XLARGE))); + + } + + public void testGetApplicationLabelAndIcon() throws Exception { + ManifestInfo info = getManifestInfo( + "<manifest xmlns:android='http://schemas.android.com/apk/res/android'\n" + + " package='com.android.unittest'>\n" + + " <application android:icon=\"@drawable/icon\"\n" + + " android:label=\"@string/app_name\">\n" + + " </application>\n" + + "" + + "</manifest>\n"); + Map<String, ActivityAttributes> map = info.getActivityAttributesMap(); + assertEquals(map.toString(), 0, map.size()); + assertEquals("com.android.unittest", info.getPackage()); + + assertEquals("Theme", ResourceHelper.styleToTheme(info.getDefaultTheme(null, NORMAL))); + assertEquals("@drawable/icon", info.getApplicationIcon()); + assertEquals("@string/app_name", info.getApplicationLabel()); + } + + public void testGetApplicationNoLabelOrIcon() throws Exception { + ManifestInfo info = getManifestInfo( + "<manifest xmlns:android='http://schemas.android.com/apk/res/android'\n" + + " package='com.android.unittest'>\n" + + " <application>\n" + + " </application>\n" + + "" + + "</manifest>\n"); + Map<String, ActivityAttributes> map = info.getActivityAttributesMap(); + assertEquals(map.toString(), 0, map.size()); + assertEquals("com.android.unittest", info.getPackage()); + + assertEquals("Theme", ResourceHelper.styleToTheme(info.getDefaultTheme(null, NORMAL))); + assertNull(info.getApplicationIcon()); + assertNull(info.getApplicationLabel()); + } + + private ManifestInfo getManifestInfo(String manifestContents) throws Exception { + InputStream bstream = new ByteArrayInputStream( + manifestContents.getBytes("UTF-8")); //$NON-NLS-1$ + + IFile file = getProject().getFile("AndroidManifest.xml"); + if (file.exists()) { + file.setContents(bstream, IFile.FORCE, new NullProgressMonitor()); + } else { + file.create(bstream, false /* force */, new NullProgressMonitor()); + } + ManifestInfo info = ManifestInfo.get(getProject()); + info.clear(); + return info; + } + + public void testGetMinSdkVersionName() throws Exception { + ManifestInfo info; + + info = getManifestInfo( + "<manifest xmlns:android='http://schemas.android.com/apk/res/android'\n" + + " package='com.android.unittest'>\n" + + " <uses-sdk android:minSdkVersion='3' android:targetSdkVersion='4'/>\n" + + "</manifest>\n"); + assertEquals(3, info.getMinSdkVersion()); + assertEquals("3", info.getMinSdkName()); + assertEquals(4, info.getTargetSdkVersion()); + assertNull(info.getMinSdkCodeName()); + + info = getManifestInfo( + "<manifest xmlns:android='http://schemas.android.com/apk/res/android'\n" + + " package='com.android.unittest'>\n" + + " <uses-sdk android:targetSdkVersion='4'/>\n" + + "</manifest>\n"); + assertEquals("1", info.getMinSdkName()); + assertEquals(1, info.getMinSdkVersion()); + assertEquals(4, info.getTargetSdkVersion()); + assertNull(info.getMinSdkCodeName()); + + info = getManifestInfo( + "<manifest xmlns:android='http://schemas.android.com/apk/res/android'\n" + + " package='com.android.unittest'>\n" + + " <uses-sdk android:minSdkVersion='JellyBean' />\n" + + "</manifest>\n"); + assertEquals("JellyBean", info.getMinSdkName()); + assertEquals("JellyBean", info.getMinSdkCodeName()); + } + + private static class TestAndroidTarget implements IAndroidTarget { + private final int mApiLevel; + + public TestAndroidTarget(int apiLevel) { + mApiLevel = apiLevel; + } + + @Override + public boolean canRunOn(IAndroidTarget target) { + return false; + } + + @Override + public String getClasspathName() { + return null; + } + + @Override + public File getDefaultSkin() { + return null; + } + + @Override + public String getDescription() { + return null; + } + + @Override + public String getFullName() { + return null; + } + + @Override + public ISystemImage getSystemImage(IdDisplay tag, String abiType) { + return null; + } + + @Override + public ISystemImage[] getSystemImages() { + return new ISystemImage[0]; + } + + @Override + public String getLocation() { + return null; + } + + @Override + public String getName() { + return null; + } + + @Override + public IOptionalLibrary[] getOptionalLibraries() { + return null; + } + + @Override + public IAndroidTarget getParent() { + return null; + } + + @Override + public String getPath(int pathId) { + return null; + } + + @Override + public File getFile(int pathId) { + return null; + } + + + @Override + public String[] getPlatformLibraries() { + return null; + } + + @Override + public Map<String, String> getProperties() { + return null; + } + + @Override + public String getProperty(String name) { + return null; + } + + @Override + public Integer getProperty(String name, Integer defaultValue) { + return null; + } + + @Override + public Boolean getProperty(String name, Boolean defaultValue) { + return null; + } + + @Override + public int getRevision() { + return 0; + } + + @Override + public File[] getSkins() { + return null; + } + + @Override + public int getUsbVendorId() { + return 0; + } + + @Override + public String getVendor() { + return null; + } + + @Override + public AndroidVersion getVersion() { + return new AndroidVersion(mApiLevel, null); + } + + @Override + public String getVersionName() { + return null; + } + + @Override + public String hashString() { + return null; + } + + @Override + public boolean isPlatform() { + return false; + } + + @Override + public int compareTo(IAndroidTarget o) { + return 0; + } + + @Override + public boolean hasRenderingLibrary() { + return false; + } + + @Override + public String getShortClasspathName() { + return null; + } + + @Override + @NonNull + public List<String> getBootClasspath() { + return new ArrayList<String>(); + } + + @Override + public BuildToolInfo getBuildToolInfo() { + return null; + } + } +} diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/launch/JUnitLaunchConfigDelegateTest.java b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/launch/JUnitLaunchConfigDelegateTest.java new file mode 100644 index 000000000..58f686adc --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/launch/JUnitLaunchConfigDelegateTest.java @@ -0,0 +1,114 @@ +/* + * Copyright (C) 2009 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.launch; + +import com.android.ide.eclipse.adt.internal.launch.JUnitLaunchConfigDelegate; + +import java.io.IOException; +import java.util.Arrays; +import junit.framework.TestCase; + +public class JUnitLaunchConfigDelegateTest extends TestCase { + + public void testAbleToFetchJunitJar() throws IOException { + assertTrue(JUnitLaunchConfigDelegate.getJunitJarLocation().endsWith("junit.jar")); + } + + public void testFixBootpathExtWithAndroidJar() { + String[][] testArray = { + null, + {}, + { "android.jar"}, + null, + { "some_other_jar.jar" }, + }; + + String[][] expectedArray = { + null, + {}, + null, + null, + { "some_other_jar.jar" }, + }; + + assertEqualsArrays(expectedArray, JUnitLaunchConfigDelegate.fixBootpathExt(testArray)); + } + + public void testFixBootpathExtWithNoAndroidJar() { + String[][] testArray = { + null, + { "somejar.jar"}, + null, + }; + + String[][] expectedArray = { + null, + { "somejar.jar"}, + null, + }; + + assertEqualsArrays(expectedArray, JUnitLaunchConfigDelegate.fixBootpathExt(testArray)); + } + + public void testFixClasspathWithJunitJar() throws IOException { + String[] testArray = { + JUnitLaunchConfigDelegate.getJunitJarLocation(), + }; + + String[] expectedArray = { + JUnitLaunchConfigDelegate.getJunitJarLocation(), + }; + + assertEqualsArrays(expectedArray, + JUnitLaunchConfigDelegate.fixClasspath(testArray, "test")); + } + + public void testFixClasspathWithoutJunitJar() throws IOException { + String[] testArray = { + "random.jar", + }; + + String[] expectedArray = { + "random.jar", + JUnitLaunchConfigDelegate.getJunitJarLocation(), + }; + + assertEqualsArrays(expectedArray, + JUnitLaunchConfigDelegate.fixClasspath(testArray, "test")); + } + + + public void testFixClasspathWithNoJars() throws IOException { + String[] testArray = { + }; + + String[] expectedArray = { + JUnitLaunchConfigDelegate.getJunitJarLocation(), + }; + + assertEqualsArrays(expectedArray, + JUnitLaunchConfigDelegate.fixClasspath(testArray, "test")); + } + + private void assertEqualsArrays(String[][] a1, String[][] a2) { + assertTrue(Arrays.deepEquals(a1, a2)); + } + + private void assertEqualsArrays(String[] a1, String[] a2) { + assertTrue(Arrays.deepEquals(a1, a2)); + } +} diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/lint/ProjectLintConfigurationTest.java b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/lint/ProjectLintConfigurationTest.java new file mode 100644 index 000000000..f8ea8c435 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/lint/ProjectLintConfigurationTest.java @@ -0,0 +1,218 @@ +/* + * 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.lint; + +import com.android.annotations.NonNull; +import com.android.annotations.Nullable; +import com.android.ide.eclipse.adt.internal.editors.layout.refactoring.AdtProjectTest; +import com.android.tools.lint.checks.DuplicateIdDetector; +import com.android.tools.lint.checks.UnusedResourceDetector; +import com.android.tools.lint.client.api.Configuration; +import com.android.tools.lint.client.api.JavaParser; +import com.android.tools.lint.client.api.LintClient; +import com.android.tools.lint.client.api.XmlParser; +import com.android.tools.lint.detector.api.Context; +import com.android.tools.lint.detector.api.Issue; +import com.android.tools.lint.detector.api.Location; +import com.android.tools.lint.detector.api.Project; +import com.android.tools.lint.detector.api.Severity; +import com.android.tools.lint.detector.api.TextFormat; + +import org.eclipse.core.resources.IProject; + +import java.io.File; + +@SuppressWarnings("javadoc") +public class ProjectLintConfigurationTest extends AdtProjectTest { + public void testBasic() { + Configuration parent = null; + LintClient client = new TestClient(); + + File dir = getTargetDir(); + if (!dir.exists()) { + boolean ok = dir.mkdirs(); + assertTrue(dir.getPath(), ok); + } + Project project = client.getProject(dir, dir); + + ProjectLintConfiguration config = + new ProjectLintConfiguration(client, project, parent, false /*fatalOnly*/); + + Issue usuallyEnabledIssue = DuplicateIdDetector.WITHIN_LAYOUT; + Issue usuallyDisabledIssue = UnusedResourceDetector.ISSUE_IDS; + + assertTrue(config.isEnabled(usuallyEnabledIssue)); + assertFalse(config.isEnabled(usuallyDisabledIssue)); + + config.setSeverity(usuallyEnabledIssue, Severity.IGNORE); + config.setSeverity(usuallyDisabledIssue, Severity.ERROR); + assertFalse(config.isEnabled(usuallyEnabledIssue)); + assertTrue(config.isEnabled(usuallyDisabledIssue)); + + // Make a NEW config object to ensure the state is persisted properly, not just + // kept on the config object! + config = new ProjectLintConfiguration(client, project, parent, false /*fatalOnly*/); + assertFalse(config.isEnabled(usuallyEnabledIssue)); + assertTrue(config.isEnabled(usuallyDisabledIssue)); + } + + public void testInheritance() { + Configuration parent = null; + LintClient client = new TestClient(); + + File dir = getTargetDir(); + assertTrue(dir.mkdirs()); + Project project = client.getProject(dir, dir); + + File otherDir = new File(dir, "otherConfig"); + assertTrue(otherDir.mkdir()); + Project otherProject = client.getProject(otherDir, otherDir); + + ProjectLintConfiguration otherConfig = + new ProjectLintConfiguration(client, otherProject, parent, false); + + ProjectLintConfiguration config = + new ProjectLintConfiguration(client, project, otherConfig, false); + + Issue usuallyEnabledIssue = DuplicateIdDetector.WITHIN_LAYOUT; + Issue usuallyDisabledIssue = UnusedResourceDetector.ISSUE_IDS; + + assertTrue(config.isEnabled(usuallyEnabledIssue)); + assertFalse(config.isEnabled(usuallyDisabledIssue)); + + otherConfig.setSeverity(usuallyEnabledIssue, Severity.IGNORE); + otherConfig.setSeverity(usuallyDisabledIssue, Severity.ERROR); + + // Ensure inheritance works + assertFalse(config.isEnabled(usuallyEnabledIssue)); + assertTrue(config.isEnabled(usuallyDisabledIssue)); + + // Revert + otherConfig.setSeverity(usuallyEnabledIssue, Severity.ERROR); + otherConfig.setSeverity(usuallyDisabledIssue, Severity.IGNORE); + assertTrue(config.isEnabled(usuallyEnabledIssue)); + assertFalse(config.isEnabled(usuallyDisabledIssue)); + + // Now override in child + config.setSeverity(usuallyEnabledIssue, Severity.ERROR); + config.setSeverity(usuallyDisabledIssue, Severity.IGNORE); + assertTrue(config.isEnabled(usuallyEnabledIssue)); + assertFalse(config.isEnabled(usuallyDisabledIssue)); + + // Now change in parent: no change in child + otherConfig.setSeverity(usuallyEnabledIssue, Severity.IGNORE); + otherConfig.setSeverity(usuallyDisabledIssue, Severity.ERROR); + assertTrue(config.isEnabled(usuallyEnabledIssue)); + assertFalse(config.isEnabled(usuallyDisabledIssue)); + assertFalse(otherConfig.isEnabled(usuallyEnabledIssue)); + assertTrue(otherConfig.isEnabled(usuallyDisabledIssue)); + + // Clear override in child + config.setSeverity(usuallyEnabledIssue, null); + config.setSeverity(usuallyDisabledIssue, null); + assertFalse(config.isEnabled(usuallyEnabledIssue)); + assertTrue(config.isEnabled(usuallyDisabledIssue)); + } + + public void testBulkEditing() { + Configuration parent = null; + LintClient client = new TestClient(); + + File dir = getTargetDir(); + assertTrue(dir.mkdirs()); + Project project = client.getProject(dir, dir); + + ProjectLintConfiguration config = + new ProjectLintConfiguration(client, project, parent, false /*fatalOnly*/); + + Issue usuallyEnabledIssue = DuplicateIdDetector.WITHIN_LAYOUT; + Issue usuallyDisabledIssue = UnusedResourceDetector.ISSUE_IDS; + + assertTrue(config.isEnabled(usuallyEnabledIssue)); + assertFalse(config.isEnabled(usuallyDisabledIssue)); + + config.setSeverity(usuallyEnabledIssue, Severity.IGNORE); + assertFalse(config.isEnabled(usuallyEnabledIssue)); + assertFalse(config.isEnabled(usuallyDisabledIssue)); + + File configFile = new File(dir, "lint.xml"); + assertTrue(configFile.getPath(), configFile.exists()); + long lastModified = configFile.lastModified(); + + // We need to make sure that the timestamp of the file is a couple of seconds + // after the last update or we can't tell whether the file was updated or not + + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + System.err.println("Sleep interrupted, test may not work."); + } + config.startBulkEditing(); + assertFalse(lastModified < configFile.lastModified()); + assertEquals(lastModified, configFile.lastModified()); + config.setSeverity(usuallyDisabledIssue, Severity.ERROR); + config.finishBulkEditing(); + assertTrue(lastModified < configFile.lastModified()); + + assertTrue(config.isEnabled(usuallyDisabledIssue)); + } + + public void testPersistence() { + // Ensure that we use the same configuration object repeatedly for a + // single project, such that we don't recompute and parse XML for each and + // every lint run! + IProject project = getProject(); + TestClient client = new TestClient(); + ProjectLintConfiguration config1 = ProjectLintConfiguration.get(client, project, false); + ProjectLintConfiguration config2 = ProjectLintConfiguration.get(client, project, false); + assertSame(config1, config2); + } + + @Override + protected File getTargetDir() { + File targetDir = new File(getTempDir(), getClass().getSimpleName() + "_" + getName()); + addCleanupDir(targetDir); + return targetDir; + } + + private static class TestClient extends LintClient { + @Override + public void report(@NonNull Context context, @NonNull Issue issue, + @NonNull Severity severity, @Nullable Location location, + @NonNull String message, @NonNull TextFormat format) { + } + + @Override + public void log(@NonNull Severity severity, @Nullable Throwable exception, + @Nullable String format, @Nullable Object... args) { + } + + @Override + public XmlParser getXmlParser() { + return null; + } + + @Override + public @NonNull String readFile(@NonNull File file) { + return null; + } + + @Override + public JavaParser getJavaParser(@Nullable Project project) { + return null; + } + } +} diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/refactorings/core/AndroidPackageRenameParticipantTest.java b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/refactorings/core/AndroidPackageRenameParticipantTest.java new file mode 100644 index 000000000..1df0b0c5e --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/refactorings/core/AndroidPackageRenameParticipantTest.java @@ -0,0 +1,293 @@ +/* + * Copyright (C) 2012 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.refactorings.core; + +import com.android.annotations.NonNull; +import com.android.ide.eclipse.adt.internal.editors.manifest.ManifestInfo; +import com.android.ide.eclipse.adt.internal.project.BaseProjectHelper; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.jdt.core.IJavaProject; +import org.eclipse.jdt.core.IPackageFragment; +import org.eclipse.jdt.core.JavaModelException; +import org.eclipse.jdt.internal.corext.refactoring.rename.RenamePackageProcessor; +import org.eclipse.ltk.core.refactoring.participants.RenameRefactoring; + +/** + * TODO: Test renaming a DIFFERENT package than the application package! + */ +@SuppressWarnings({"javadoc", "restriction"}) +public class AndroidPackageRenameParticipantTest extends RefactoringTestBase { + public void testRefactor1() throws Exception { + renamePackage( + TEST_PROJECT, + false /*renameSubpackages*/, + true /*updateReferences*/, + "my.pkg.name", + + "CHANGES:\n" + + "-------\n" + + "[x] Rename package 'com.example.refactoringtest' to 'my.pkg.name'\n" + + "\n" + + "[x] MainActivity.java - /testRefactor1/src/com/example/refactoringtest/MainActivity.java\n" + + " @@ -3 +3\n" + + " + import com.example.refactoringtest.R;\n" + + " +\n" + + "\n" + + "\n" + + "[x] activity_main.xml - /testRefactor1/res/layout/activity_main.xml\n" + + " @@ -33 +33\n" + + " - <fragment android:name=\"com.example.refactoringtest.MyFragment\"/>\n" + + " + <fragment android:name=\"my.pkg.name.MyFragment\"/>\n" + + "\n" + + "\n" + + "[x] AndroidManifest.xml - /testRefactor1/AndroidManifest.xml\n" + + " @@ -16 +16\n" + + " - android:name=\"com.example.refactoringtest.MainActivity\"\n" + + " + android:name=\"my.pkg.name.MainActivity\"\n" + + " @@ -25 +25\n" + + " - android:name=\".MainActivity2\"\n" + + " + android:name=\"my.pkg.name.MainActivity2\"", + true); + } + + public void testRefactor1_noreferences() throws Exception { + renamePackage( + TEST_PROJECT, + false /*renameSubpackages*/, + false /*updateReferences*/, + "my.pkg.name", + + "CHANGES:\n" + + "-------\n" + + "[x] Rename package 'com.example.refactoringtest' to 'my.pkg.name'", + false); + } + + public void testRefactor2() throws Exception { + // Tests custom view handling + renamePackage( + TEST_PROJECT2, + false /*renameSubpackages*/, + true /*updateReferences*/, + "my.pkg.name", + + "CHANGES:\n" + + "-------\n" + + "[x] Rename package 'com.example.refactoringtest' to 'my.pkg.name'\n" + + "\n" + + "[x] MainActivity.java - /testRefactor2/src/com/example/refactoringtest/MainActivity.java\n" + + " @@ -3 +3\n" + + " + import com.example.refactoringtest.R;\n" + + " +\n" + + "\n" + + "\n" + + "[x] customviews.xml - /testRefactor2/res/layout/customviews.xml\n" + + " @@ -9 +9\n" + + " - <com.example.refactoringtest.CustomView1\n" + + " + <my.pkg.name.CustomView1\n" + + "\n" + + "\n" + + "[x] activity_main.xml - /testRefactor2/res/layout/activity_main.xml\n" + + " @@ -33 +33\n" + + " - <fragment android:name=\"com.example.refactoringtest.MyFragment\"/>\n" + + " + <fragment android:name=\"my.pkg.name.MyFragment\"/>\n" + + "\n" + + "\n" + + "[x] customviews.xml - /testRefactor2/res/layout-land/customviews.xml\n" + + " @@ -9 +9\n" + + " - <com.example.refactoringtest.CustomView1\n" + + " + <my.pkg.name.CustomView1\n" + + "\n" + + "\n" + + "[x] AndroidManifest.xml - /testRefactor2/AndroidManifest.xml\n" + + " @@ -16 +16\n" + + " - android:name=\"com.example.refactoringtest.MainActivity\"\n" + + " + android:name=\"my.pkg.name.MainActivity\"\n" + + " @@ -25 +25\n" + + " - android:name=\".MainActivity2\"\n" + + " + android:name=\"my.pkg.name.MainActivity2\"", + true); + } + + public void testRefactor2_renamesub() throws Exception { + // Tests custom view handling + renamePackage( + TEST_PROJECT2, + true /*renameSubpackages*/, + true /*updateReferences*/, + "my.pkg.name", + + "CHANGES:\n" + + "-------\n" + + "[x] Rename package 'com.example.refactoringtest' and subpackages to 'my.pkg.name'\n" + + "\n" + + "[x] MainActivity.java - /testRefactor2_renamesub/src/com/example/refactoringtest/MainActivity.java\n" + + " @@ -3 +3\n" + + " + import com.example.refactoringtest.R;\n" + + " +\n" + + "\n" + + "\n" + + "[x] customviews.xml - /testRefactor2_renamesub/res/layout/customviews.xml\n" + + " @@ -9 +9\n" + + " - <com.example.refactoringtest.CustomView1\n" + + " + <my.pkg.name.CustomView1\n" + + "\n" + + "\n" + + "[x] activity_main.xml - /testRefactor2_renamesub/res/layout/activity_main.xml\n" + + " @@ -33 +33\n" + + " - <fragment android:name=\"com.example.refactoringtest.MyFragment\"/>\n" + + " + <fragment android:name=\"my.pkg.name.MyFragment\"/>\n" + + "\n" + + "\n" + + "[x] customviews.xml - /testRefactor2_renamesub/res/layout-land/customviews.xml\n" + + " @@ -9 +9\n" + + " - <com.example.refactoringtest.CustomView1\n" + + " + <my.pkg.name.CustomView1\n" + + "\n" + + "\n" + + "[x] AndroidManifest.xml - /testRefactor2_renamesub/AndroidManifest.xml\n" + + " @@ -16 +16\n" + + " - android:name=\"com.example.refactoringtest.MainActivity\"\n" + + " + android:name=\"my.pkg.name.MainActivity\"\n" + + " @@ -25 +25\n" + + " - android:name=\".MainActivity2\"\n" + + " + android:name=\"my.pkg.name.MainActivity2\"\n" + + "\n" + + "\n" + + "[x] customviews.xml - /testRefactor2_renamesub/res/layout/customviews.xml\n" + + " @@ -15 +15\n" + + " - <com.example.refactoringtest.subpackage.CustomView2\n" + + " + <my.pkg.name.subpackage.CustomView2\n" + + "\n" + + "\n" + + "[x] customviews.xml - /testRefactor2_renamesub/res/layout-land/customviews.xml\n" + + " @@ -15 +15\n" + + " - <com.example.refactoringtest.subpackage.CustomView2\n" + + " + <my.pkg.name.subpackage.CustomView2", + true); + } + + public void testRefactor2_renamesub_norefs() throws Exception { + // Tests custom view handling + renamePackage( + TEST_PROJECT2, + true /*renameSubpackages*/, + false /*updateReferences*/, + "my.pkg.name", + + "CHANGES:\n" + + "-------\n" + + "[x] Rename package 'com.example.refactoringtest' and subpackages to 'my.pkg.name'", + false); + } + + + // ---- Test infrastructure ---- + + protected void renamePackage( + @NonNull Object[] testData, + boolean renameSubpackages, + boolean updateReferences, + @NonNull String newName, + @NonNull String expected, + boolean expectedAppPackageRenameWarning) throws Exception { + IProject project = createProject(testData); + String expectedWarnings = expectedAppPackageRenameWarning ? + EXPECTED_WARNINGS_TEMPLATE.replace("PROJECTNAME", project.getName()) : null; + renamePackage(project, renameSubpackages, updateReferences, newName, expected, + expectedWarnings); + } + + protected void renamePackage( + @NonNull IProject project, + boolean renameSubpackages, + boolean updateReferences, + @NonNull String newName, + @NonNull String expected, + @NonNull String expectedWarnings) throws Exception { + ManifestInfo info = ManifestInfo.get(project); + String currentPackage = info.getPackage(); + assertNotNull(currentPackage); + + IPackageFragment pkgFragment = getPackageFragment(project, currentPackage); + RenamePackageProcessor processor = new RenamePackageProcessor(pkgFragment); + processor.setNewElementName(newName); + processor.setRenameSubpackages(renameSubpackages); + processor.setUpdateReferences(updateReferences); + assertNotNull(processor); + + RenameRefactoring refactoring = new RenameRefactoring(processor); + checkRefactoring(refactoring, expected, expectedWarnings); + } + + private static IPackageFragment getPackageFragment(IProject project, String pkg) + throws CoreException, JavaModelException { + IPackageFragment pkgFragment = null; + IJavaProject javaProject = BaseProjectHelper.getJavaProject(project); + assertNotNull(javaProject); + IPackageFragment[] fragments = javaProject.getPackageFragments(); + for (IPackageFragment fragment : fragments) { + String name = fragment.getElementName(); + if (pkg.equals(name)) { + pkgFragment = fragment; + break; + } + } + return pkgFragment; + } + + private static String EXPECTED_WARNINGS_TEMPLATE = + "<INFO\n" + + "\t\n" + + "INFO: You are refactoring the same package as your application's package (specified in the manifest).\n" + + "\n" + + "Context: L/PROJECTNAME/AndroidManifest.xml\n" + + "code: none\n" + + "Data: null\n" + + "\t\n" + + "INFO: Note that this refactoring does NOT also update your application package.\n" + + "Context: L/PROJECTNAME/AndroidManifest.xml\n" + + "code: none\n" + + "Data: null\n" + + "\t\n" + + "INFO: The application package defines your application's identity.\n" + + "Context: L/PROJECTNAME/AndroidManifest.xml\n" + + "code: none\n" + + "Data: null\n" + + "\t\n" + + "INFO: If you change it, then it is considered to be a different application.\n" + + "Context: L/PROJECTNAME/AndroidManifest.xml\n" + + "code: none\n" + + "Data: null\n" + + "\t\n" + + "INFO: (Users of the previous version cannot update to the new version.)\n" + + "Context: L/PROJECTNAME/AndroidManifest.xml\n" + + "code: none\n" + + "Data: null\n" + + "\t\n" + + "INFO: The application package, and the package containing the code, can differ.\n" + + "Context: L/PROJECTNAME/AndroidManifest.xml\n" + + "code: none\n" + + "Data: null\n" + + "\t\n" + + "INFO: To really change application package, choose \"Android Tools\" > \"Rename Application Package.\" from the project context menu.\n" + + "Context: L/PROJECTNAME/AndroidManifest.xml\n" + + "code: none\n" + + "Data: null\n" + + ">"; +} diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/refactorings/core/RefactoringTestBase.java b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/refactorings/core/RefactoringTestBase.java new file mode 100644 index 000000000..41838e24b --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/refactorings/core/RefactoringTestBase.java @@ -0,0 +1,757 @@ +/* + * Copyright (C) 2012 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.refactorings.core; + +import com.android.annotations.NonNull; +import com.android.annotations.Nullable; +import com.android.ide.eclipse.adt.AdtUtils; +import com.android.ide.eclipse.adt.internal.editors.layout.refactoring.AdtProjectTest; +import com.google.common.base.Charsets; +import com.google.common.base.Splitter; +import com.google.common.io.ByteStreams; +import com.google.common.io.Files; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.jdt.internal.corext.refactoring.changes.RenameCompilationUnitChange; +import org.eclipse.jdt.internal.corext.refactoring.changes.RenamePackageChange; +import org.eclipse.jface.text.Document; +import org.eclipse.jface.text.IDocument; +import org.eclipse.ltk.core.refactoring.Change; +import org.eclipse.ltk.core.refactoring.CompositeChange; +import org.eclipse.ltk.core.refactoring.Refactoring; +import org.eclipse.ltk.core.refactoring.RefactoringStatus; +import org.eclipse.ltk.core.refactoring.TextChange; +import org.eclipse.ltk.core.refactoring.TextFileChange; +import org.eclipse.ltk.core.refactoring.resource.MoveResourceChange; +import org.eclipse.ltk.core.refactoring.resource.RenameResourceChange; +import org.eclipse.text.edits.TextEdit; + +import java.io.File; +import java.io.IOException; +import java.util.Arrays; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; + +@SuppressWarnings({"javadoc","restriction"}) +public abstract class RefactoringTestBase extends AdtProjectTest { + protected void checkRefactoring(Refactoring refactoring, String expected) throws Exception { + checkRefactoring(refactoring, expected, null); + } + + @Override + protected void setUp() throws Exception { + // Not calling super.setUp + } + + protected void checkRefactoring(Refactoring refactoring, String expected, + @Nullable String expectedWarnings) throws Exception { + RefactoringStatus status = refactoring.checkAllConditions(new NullProgressMonitor()); + assertNotNull(status); + if (expectedWarnings == null) { + expectedWarnings = "<OK\n>"; + } + if (status.toString().trim().startsWith( + "<WARNING\n" + + "\t\n" + + "WARNING: Code modification may not be accurate as affected resource '")) { + // Test instability, probably a timing issue with getting the new project + // compiled (to recognize Android classpath entries) + // Just continue to ensure that the refactoring list matches. + } else { + assertEquals(status.toString().trim(), expectedWarnings.trim()); + } + if (!status.isOK()) { + return; + } + assertTrue(status.toString(), status.isOK()); + Change change = refactoring.createChange(new NullProgressMonitor()); + assertNotNull(change); + String explanation = "CHANGES:\n-------\n" + describe(change); + if (!expected.trim().equals(explanation.trim())) { // allow trimming endlines in expected + assertEquals(expected, explanation); + } + } + + private IProject mProject; + + @Override + protected IProject getProject() { + return mProject; + } + + protected IProject createProject(Object[] testData) throws Exception { + String name = getName(); + IProject project = createProject(name); + mProject = project; + File projectDir = AdtUtils.getAbsolutePath(project).toFile(); + assertNotNull(projectDir); + assertTrue(projectDir.getPath(), projectDir.exists()); + createTestDataDir(projectDir, testData); + project.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor()); + + for (int i = 0; i < testData.length; i+= 2) { + assertTrue(testData[i].toString(), testData[i] instanceof String); + String relative = (String) testData[i]; + IResource member = project.findMember(relative); + assertNotNull(relative, member); + assertTrue(member.getClass().getSimpleName(), member instanceof IFile); + } + + return project; + } + + public static String describe(Change change) throws Exception { + StringBuilder sb = new StringBuilder(1000); + describe(sb, change, 0); + + // Trim trailing space + for (int i = sb.length() - 1; i >= 0; i--) { + if (!Character.isWhitespace(sb.charAt(i))) { + sb.setLength(i + 1); + break; + } + } + + return sb.toString(); + } + + protected static void describe(StringBuilder sb, Change change, int indent) throws Exception { + if (change instanceof CompositeChange + && ((CompositeChange) change).isSynthetic()) { + // Don't display information about synthetic changes + } else { + String changeName = change.getName(); + + if (changeName.contains("MoreUnit")) { + // If MoreUnit plugin is installed, don't include in unit test results + return; + } + + // Describe this change + indent(sb, indent); + if (change.isEnabled()) { + sb.append("[x] "); + } else { + sb.append("[ ] "); + } + sb.append(changeName); + + IFile file = getFile(change); + if (file != null) { + sb.append(" - "); + sb.append(file.getFullPath()); + sb.append('\n'); + } else { + sb.append('\n'); + } + + if (change instanceof TextFileChange) { + assertNotNull(file); + if (file != null) { + TextChange tc = (TextChange) change; + TextEdit edit = tc.getEdit(); + byte[] bytes = ByteStreams.toByteArray(file.getContents()); + String before = new String(bytes, Charsets.UTF_8); + IDocument document = new Document(); + document.replace(0, 0, before); + // Make a copy: edits are sometimes destructive when run repeatedly! + edit.copy().apply(document); + String after = document.get(); + + String diff = getDiff(before, after); + for (String line : Splitter.on('\n').split(diff)) { + if (!line.trim().isEmpty()) { + indent(sb, indent + 1); + sb.append(line); + } + sb.append('\n'); + } + } + } else if (change instanceof RenameCompilationUnitChange) { + // Change name, appended above, is adequate + } else if (change instanceof RenameResourceChange) { + // Change name, appended above, is adequate + } else if (change instanceof RenamePackageChange) { + // Change name, appended above, is adequate + } else if (change instanceof MoveResourceChange) { + // Change name, appended above, is adequate + } else if (change instanceof CompositeChange) { + // Don't print details about children here; they'll be nested below + } else { + indent(sb, indent); + sb.append("<UNKNOWN CHANGE TYPE " + change.getClass().getName() + ">"); + } + sb.append('\n'); + } + + if (change instanceof CompositeChange) { + CompositeChange composite = (CompositeChange) change; + Change[] children = composite.getChildren(); + List<Change> sorted = Arrays.asList(children); + // Process children in a fixed (output-alphabetical) order to ensure stable output + Collections.sort(sorted, new Comparator<Change>() { + @Override + public int compare(Change change1, Change change2) { + try { + IFile file1 = getFile(change1); + IFile file2 = getFile(change2); + if (file1 != null && file2 != null) { + // Sort in decreasing order. This places the most interesting + // files first: res > src > gen + int fileDelta = file2.getFullPath().toOSString().compareToIgnoreCase( + file1.getFullPath().toOSString()); + if (fileDelta != 0) { + return fileDelta; + } + } + + int nameDelta = change2.getName().compareTo(change1.getName()); + if (nameDelta != 0) { + return nameDelta; + } + + // This is pretty inefficient but ensures stable output + return describe(change2).compareTo(describe(change1)); + } catch (Exception e) { + fail(e.getLocalizedMessage()); + return 0; + } + } + + }); + for (Change child : sorted) { + describe(sb, child, indent + (composite.isSynthetic() ? 0 : 1)); + } + } + } + + @Nullable + private static IFile getFile(@NonNull Change change) { + if (change instanceof TextFileChange) { + TextFileChange tfc = (TextFileChange) change; + return tfc.getFile(); + } + + return null; + } + + protected static void indent(StringBuilder sb, int indent) { + for (int i = 0; i < indent; i++) { + sb.append(" "); + } + } + + protected void createTestDataDir(File dir, Object[] data) throws IOException { + for (int i = 0, n = data.length; i < n; i += 2) { + assertTrue("Must be a path: " + data[i], data[i] instanceof String); + String relativePath = ((String) data[i]).replace('/', File.separatorChar); + File to = new File(dir, relativePath); + File parent = to.getParentFile(); + if (!parent.exists()) { + boolean mkdirs = parent.mkdirs(); + assertTrue(to.getPath(), mkdirs); + } + + Object o = data[i + 1]; + if (o instanceof String) { + String contents = (String) o; + Files.write(contents, to, Charsets.UTF_8); + } else if (o instanceof byte[]) { + Files.write((byte[]) o, to); + } else { + fail("Data must be a String or a byte[] for " + to); + } + } + } + + // Test sources + + protected static final String SAMPLE_MANIFEST = + "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + + "<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" + + " package=\"com.example.refactoringtest\"\n" + + " android:versionCode=\"1\"\n" + + " android:versionName=\"1.0\" >\n" + + "\n" + + " <uses-sdk\n" + + " android:minSdkVersion=\"8\"\n" + + " android:targetSdkVersion=\"17\" />\n" + + "\n" + + " <application\n" + + " android:icon=\"@drawable/ic_launcher\"\n" + + " android:label=\"@string/app_name\"\n" + + " android:theme=\"@style/AppTheme\" >\n" + + " <activity\n" + + " android:name=\"com.example.refactoringtest.MainActivity\"\n" + + " android:label=\"@string/app_name\" >\n" + + " <intent-filter>\n" + + " <action android:name=\"android.intent.action.MAIN\" />\n" + + "\n" + + " <category android:name=\"android.intent.category.LAUNCHER\" />\n" + + " </intent-filter>\n" + + " </activity>\n" + + " <activity\n" + + " android:name=\".MainActivity2\"\n" + + " android:label=\"@string/app_name2\" >\n" + + " </activity>\n" + + " </application>\n" + + "\n" + + "</manifest>"; + + protected static final String SAMPLE_MAIN_ACTIVITY = + "package com.example.refactoringtest;\n" + + "\n" + + "import android.os.Bundle;\n" + + "import android.app.Activity;\n" + + "import android.view.Menu;\n" + + "import android.view.View;\n" + + "\n" + + "public class MainActivity extends Activity {\n" + + "\n" + + " @Override\n" + + " protected void onCreate(Bundle savedInstanceState) {\n" + + " super.onCreate(savedInstanceState);\n" + + " setContentView(R.layout.activity_main);\n" + + " View view1 = findViewById(R.id.textView1);\n" + + " }\n" + + "\n" + + " @Override\n" + + " public boolean onCreateOptionsMenu(Menu menu) {\n" + + " // Inflate the menu; this adds items to the action bar if it is present.\n" + + " getMenuInflater().inflate(R.menu.activity_main, menu);\n" + + " return true;\n" + + " }\n" + + "\n" + + "}\n"; + + protected static final String SAMPLE_MAIN_ACTIVITY2 = + "package com.example.refactoringtest;\n" + + "\n" + + "import android.os.Bundle;\n" + + "import android.app.Activity;\n" + + "import android.view.Menu;\n" + + "import android.view.View;\n" + + "\n" + + "public class MainActivity2 extends Activity {\n" + + "\n" + + " @Override\n" + + " protected void onCreate(Bundle savedInstanceState) {\n" + + " super.onCreate(savedInstanceState);\n" + + " }\n" + + "\n" + + "}\n"; + + protected static final String MY_FRAGMENT = + "package com.example.refactoringtest;\n" + + "import android.support.v4.app.ListFragment;\n" + + "\n" + + "public class MyFragment extends ListFragment {\n" + + "\n" + + "}\n"; + + protected static final String SAMPLE_LAYOUT = + "<RelativeLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" + + " xmlns:tools=\"http://schemas.android.com/tools\"\n" + + " android:layout_width=\"match_parent\"\n" + + " android:layout_height=\"match_parent\"\n" + + " tools:context=\".MainActivity\" >\n" + + "\n" + + " <TextView\n" + + " android:id=\"@+id/textView1\"\n" + + " android:layout_width=\"wrap_content\"\n" + + " android:layout_height=\"wrap_content\"\n" + + " android:layout_centerVertical=\"true\"\n" + + " android:layout_toRightOf=\"@+id/button2\"\n" + + " android:text=\"@string/hello_world\" />\n" + + "\n" + + " <Button\n" + + " android:id=\"@+id/button1\"\n" + + " android:layout_width=\"wrap_content\"\n" + + " android:layout_height=\"wrap_content\"\n" + + " android:layout_alignLeft=\"@+id/textView1\"\n" + + " android:layout_below=\"@+id/textView1\"\n" + + " android:layout_marginLeft=\"22dp\"\n" + + " android:layout_marginTop=\"24dp\"\n" + + " android:text=\"Button\" />\n" + + "\n" + + " <Button\n" + + " android:id=\"@+id/button2\"\n" + + " android:layout_width=\"wrap_content\"\n" + + " android:layout_height=\"wrap_content\"\n" + + " android:layout_alignParentLeft=\"true\"\n" + + " android:layout_alignParentTop=\"true\"\n" + + " android:text=\"Button\" />\n" + + "\n" + + " <fragment android:name=\"com.example.refactoringtest.MyFragment\"/>" + + "\n" + + "</RelativeLayout>"; + + protected static final String SAMPLE_LAYOUT_2 = + "<RelativeLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" + + " xmlns:tools=\"http://schemas.android.com/tools\"\n" + + " android:layout_width=\"match_parent\"\n" + + " android:layout_height=\"match_parent\"\n" + + " tools:context=\".MainActivity\" >\n" + + "\n" + + " <ListView\n" + + " android:layout_width=\"match_parent\"\n" + + " android:layout_height=\"wrap_content\"\n" + + " tools:listitem=\"@layout/preview\" >\n" + + " </ListView>\n" + + "\n" + + " <fragment\n" + + " android:name=\"android.support.v4.app.ListFragment\"\n" + + " android:layout_width=\"wrap_content\"\n" + + " android:layout_height=\"wrap_content\"\n" + + " tools:layout=\"@layout/preview\" />\n" + + "\n" + + "\n" + + "</RelativeLayout>"; + + + protected static final String SAMPLE_MENU = + "<menu xmlns:android=\"http://schemas.android.com/apk/res/android\" >\n" + + "\n" + + " <item\n" + + " android:id=\"@+id/menu_settings\"\n" + + " android:orderInCategory=\"100\"\n" + + " android:showAsAction=\"never\"\n" + + " android:title=\"@string/menu_settings\"/>\n" + + "\n" + + "</menu>"; + + protected static final String SAMPLE_STRINGS = + "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + + "<resources>\n" + + "\n" + + " <string name=\"app_name\">RefactoringTest</string>\n" + + " <string name=\"hello_world\">Hello world!</string>\n" + + " <string name=\"menu_settings\">Settings</string>\n" + + "\n" + + "</resources>"; + + protected static final String SAMPLE_STYLES = + "<resources>\n" + + "\n" + + " <!--\n" + + " Base application theme, dependent on API level. This theme is replaced\n" + + " by AppBaseTheme from res/values-vXX/styles.xml on newer devices.\n" + + " -->\n" + + " <style name=\"AppBaseTheme\" parent=\"android:Theme.Light\">\n" + + " <!--\n" + + " Theme customizations available in newer API levels can go in\n" + + " res/values-vXX/styles.xml, while customizations related to\n" + + " backward-compatibility can go here.\n" + + " -->\n" + + " </style>\n" + + "\n" + + " <!-- Application theme. -->\n" + + " <style name=\"AppTheme\" parent=\"AppBaseTheme\">\n" + + " <!-- All customizations that are NOT specific to a particular API-level can go here. -->\n" + + " </style>\n" + + "\n" + + "</resources>"; + + protected static final String SAMPLE_R = + "/* AUTO-GENERATED FILE. DO NOT MODIFY.\n" + + " *\n" + + " * This class was automatically generated by the\n" + + " * aapt tool from the resource data it found. It\n" + + " * should not be modified by hand.\n" + + " */\n" + + "\n" + + "package com.example.refactoringtest;\n" + + "\n" + + "public final class R {\n" + + " public static final class attr {\n" + + " }\n" + + " public static final class drawable {\n" + + " public static final int ic_launcher=0x7f020000;\n" + + " }\n" + + " public static final class id {\n" + + " public static final int button1=0x7f070002;\n" + + " public static final int button2=0x7f070001;\n" + + " public static final int menu_settings=0x7f070003;\n" + + " public static final int textView1=0x7f070000;\n" + + " }\n" + + " public static final class layout {\n" + + " public static final int activity_main=0x7f030000;\n" + + " }\n" + + " public static final class menu {\n" + + " public static final int activity_main=0x7f060000;\n" + + " }\n" + + " public static final class string {\n" + + " public static final int app_name=0x7f040000;\n" + + " public static final int hello_world=0x7f040001;\n" + + " public static final int menu_settings=0x7f040002;\n" + + " }\n" + + " public static final class style {\n" + + " /** \n" + + " Base application theme, dependent on API level. This theme is replaced\n" + + " by AppBaseTheme from res/values-vXX/styles.xml on newer devices.\n" + + " \n" + + "\n" + + " Theme customizations available in newer API levels can go in\n" + + " res/values-vXX/styles.xml, while customizations related to\n" + + " backward-compatibility can go here.\n" + + " \n" + + "\n" + + " Base application theme for API 11+. This theme completely replaces\n" + + " AppBaseTheme from res/values/styles.xml on API 11+ devices.\n" + + " \n" + + " API 11 theme customizations can go here. \n" + + "\n" + + " Base application theme for API 14+. This theme completely replaces\n" + + " AppBaseTheme from BOTH res/values/styles.xml and\n" + + " res/values-v11/styles.xml on API 14+ devices.\n" + + " \n" + + " API 14 theme customizations can go here. \n" + + " */\n" + + " public static final int AppBaseTheme=0x7f050000;\n" + + " /** Application theme. \n" + + " All customizations that are NOT specific to a particular API-level can go here. \n" + + " */\n" + + " public static final int AppTheme=0x7f050001;\n" + + " }\n" + + "}\n"; + + protected static final Object[] TEST_PROJECT = new Object[] { + "AndroidManifest.xml", + SAMPLE_MANIFEST, + + "src/com/example/refactoringtest/MainActivity.java", + SAMPLE_MAIN_ACTIVITY, + + "src/com/example/refactoringtest/MainActivity2.java", + SAMPLE_MAIN_ACTIVITY2, + + "gen/com/example/refactoringtest/R.java", + SAMPLE_R, + + "res/drawable-xhdpi/ic_launcher.png", + new byte[] { 0 }, + "res/drawable-hdpi/ic_launcher.png", + new byte[] { 0 }, + "res/drawable-ldpi/ic_launcher.png", + new byte[] { 0 }, + "res/drawable-mdpi/ic_launcher.png", + new byte[] { 0 }, + + "res/layout/activity_main.xml", + SAMPLE_LAYOUT, + + "res/layout-land/activity_main.xml", + SAMPLE_LAYOUT_2, + + "res/menu/activity_main.xml", + SAMPLE_MENU, + + "res/values/strings.xml", // file 3 + SAMPLE_STRINGS, + + "res/values/styles.xml", // file 3 + SAMPLE_STYLES, + }; + + // More test data + + protected static final String CUSTOM_VIEW_1 = + "package com.example.refactoringtest;\n" + + "\n" + + "import android.content.Context;\n" + + "import android.widget.Button;\n" + + "\n" + + "public class CustomView1 extends Button {\n" + + " public CustomView1(Context context) {\n" + + " super(context);\n" + + " }\n" + + "}\n"; + + protected static final String CUSTOM_VIEW_1_STYLES = + "<resources>\n" + + "\n" + + " <!-- Aattributes for the custom view -->\n" + + " <declare-styleable name=\"CustomView1\">\n" + + " <attr name=\"exampleString\" format=\"string\" />\n" + + " <attr name=\"exampleDimension\" format=\"dimension\" />\n" + + " <attr name=\"exampleColor\" format=\"color\" />\n" + + " <attr name=\"exampleDrawable\" format=\"color|reference\" />\n" + + " </declare-styleable>\n" + + "\n" + + "</resources>"; + + protected static final String CUSTOM_VIEW_2 = + "package com.example.refactoringtest.subpackage;\n" + + "\n" + + "import android.content.Context;\n" + + "import android.widget.Button;\n" + + "\n" + + "public class CustomView2 extends Button {\n" + + " public CustomView2(Context context) {\n" + + " super(context);\n" + + " }\n" + + "}\n"; + + protected static final String CUSTOM_VIEW_LAYOUT = + "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + + "<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" + + " xmlns:tools=\"http://schemas.android.com/tools\"\n" + + " android:layout_width=\"match_parent\"\n" + + " android:layout_height=\"match_parent\"\n" + + " android:orientation=\"vertical\"\n" + + " tools:ignore=\"HardcodedText\" >\n" + + "\n" + + " <com.example.refactoringtest.CustomView1\n" + + " android:id=\"@+id/customView1\"\n" + + " android:layout_width=\"wrap_content\"\n" + + " android:layout_height=\"wrap_content\"\n" + + " android:text=\"CustomView1\" />\n" + + "\n" + + " <com.example.refactoringtest.subpackage.CustomView2\n" + + " android:id=\"@+id/customView2\"\n" + + " android:layout_width=\"wrap_content\"\n" + + " android:layout_height=\"wrap_content\"\n" + + " android:text=\"CustomView2\" />\n" + + "\n" + + "</LinearLayout>"; + + protected static final Object[] TEST_PROJECT2 = new Object[] { + "AndroidManifest.xml", + SAMPLE_MANIFEST, + + "src/com/example/refactoringtest/MainActivity.java", + SAMPLE_MAIN_ACTIVITY, + + "src/com/example/refactoringtest/CustomView1.java", + CUSTOM_VIEW_1, + + "res/values/attrs_custom_view.xml", + CUSTOM_VIEW_1_STYLES, + + "src/com/example/refactoringtest/subpackage/CustomView2.java", + CUSTOM_VIEW_2, + + "src/com/example/refactoringtest/MyFragment.java", + MY_FRAGMENT, + + "gen/com/example/refactoringtest/R.java", + SAMPLE_R, + + "res/drawable-xhdpi/ic_launcher.png", + new byte[] { 0 }, + "res/drawable-hdpi/ic_launcher.png", + new byte[] { 0 }, + "res/drawable-ldpi/ic_launcher.png", + new byte[] { 0 }, + "res/drawable-mdpi/ic_launcher.png", + new byte[] { 0 }, + + "res/layout/activity_main.xml", + SAMPLE_LAYOUT, + + "res/layout-land/activity_main.xml", + SAMPLE_LAYOUT_2, + + "res/layout/customviews.xml", + CUSTOM_VIEW_LAYOUT, + + "res/layout-land/customviews.xml", + CUSTOM_VIEW_LAYOUT, + + "res/menu/activity_main.xml", + SAMPLE_MENU, + + "res/values/strings.xml", // file 3 + SAMPLE_STRINGS, + + "res/values/styles.xml", // file 3 + SAMPLE_STYLES, + + // Just a gen file, should not be refactored + "bin/AndroidManifest.xml", + SAMPLE_MANIFEST, + + }; + + + protected static final String MANIFEST = + "/* AUTO-GENERATED FILE. DO NOT MODIFY.\n" + + " *\n" + + " * This class was automatically generated by the\n" + + " * aapt tool from the resource data it found. It\n" + + " * should not be modified by hand.\n" + + " */\n" + + "\n" + + "package com.example.refactoringtest;\n" + + "\n" + + "public final class Manifest {\n" + + " public static final class permission {\n" + + " public static final String WRITE_SCHEDULE=\"com.example.refactoringtest.permission.WRITE_SCHEDULE\";\n" + + " }\n" + + "}"; + + protected static final String BUILD_CONFIG = + "/** Automatically generated file. DO NOT MODIFY */\n" + + "package com.example.refactoringtest;\n" + + "\n" + + "public final class BuildConfig {\n" + + " public final static boolean DEBUG = true;\n" + + "}"; + + protected static final String MORE_CODE_JAVA = + "package com.example.refactoringtest.subpkg;\n" + + "\n" + + "import android.os.Bundle;\n" + + "import android.app.Activity;\n" + + "import android.view.Menu;\n" + + "import android.view.View;\n" + + "import com.example.refactoringtest.BuildConfig;\n" + + "import com.example.refactoringtest.Manifest;\n" + + "import com.example.refactoringtest.R;\n" + + "\n" + + "public class MoreCode extends Activity {\n" + + "\n" + + " protected void code() {\n" + + " if (BuildConfig.DEBUG) {\n" + + " System.out.println(Manifest.permission);\n" + + " }" + + " System.out.println(com.example.refactoringtest.BuildConfig.DEBUG);\n" + + " }\n" + + "\n" + + "}\n"; + + /** Project which includes references to BuildConfig, Manifest, and R */ + protected static final Object[] TEST_PROJECT3; + static { + Object[] additional = new Object[] { + "src/com/example/refactoringtest/subpkg/MoreCode.java", + MORE_CODE_JAVA, + + "gen/com/example/refactoringtest/BuildConfig.java", + BUILD_CONFIG, + + "gen/com/example/refactoringtest/Manifest.java", + MANIFEST, + }; + TEST_PROJECT3 = new Object[TEST_PROJECT2.length + additional.length]; + System.arraycopy(TEST_PROJECT2, 0, TEST_PROJECT3, 0, TEST_PROJECT2.length); + System.arraycopy(additional, 0, TEST_PROJECT3, TEST_PROJECT2.length, additional.length); + }; +} diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/refactorings/core/RenameResourceParticipantTest.java b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/refactorings/core/RenameResourceParticipantTest.java new file mode 100644 index 000000000..3f029b93b --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/refactorings/core/RenameResourceParticipantTest.java @@ -0,0 +1,402 @@ +/* + * Copyright (C) 2012 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.refactorings.core; + +import com.android.annotations.NonNull; +import com.android.ide.common.resources.ResourceUrl; +import com.android.ide.eclipse.adt.internal.project.BaseProjectHelper; +import com.android.resources.ResourceType; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.jdt.core.IField; +import org.eclipse.jdt.core.IJavaProject; +import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.internal.corext.refactoring.rename.RenameFieldProcessor; +import org.eclipse.ltk.core.refactoring.participants.RenameProcessor; +import org.eclipse.ltk.core.refactoring.participants.RenameRefactoring; + +@SuppressWarnings({"javadoc", "restriction"}) +public class RenameResourceParticipantTest extends RefactoringTestBase { + public void testRefactor1() throws Exception { + renameResource( + TEST_PROJECT, + "@string/app_name", + true /*updateReferences*/, + "myname", + + "CHANGES:\n" + + "-------\n" + + "[x] strings.xml - /testRefactor1/res/values/strings.xml\n" + + " @@ -4 +4\n" + + " - <string name=\"app_name\">RefactoringTest</string>\n" + + " + <string name=\"myname\">RefactoringTest</string>\n" + + "\n" + + "\n" + + "[ ] R.java - /testRefactor1/gen/com/example/refactoringtest/R.java\n" + + " @@ -29 +29\n" + + " - public static final int app_name=0x7f040000;\n" + + " + public static final int myname=0x7f040000;\n" + + "\n" + + "\n" + + "[x] AndroidManifest.xml - /testRefactor1/AndroidManifest.xml\n" + + " @@ -13 +13\n" + + " - android:label=\"@string/app_name\"\n" + + " + android:label=\"@string/myname\"\n" + + " @@ -17 +17\n" + + " - android:label=\"@string/app_name\" >\n" + + " + android:label=\"@string/myname\" >"); + } + + public void testRefactor2() throws Exception { + renameResource( + TEST_PROJECT, + "@+id/menu_settings", + true /*updateReferences*/, + "new_id_for_the_action_bar", + + "CHANGES:\n" + + "-------\n" + + "[x] activity_main.xml - /testRefactor2/res/menu/activity_main.xml\n" + + " @@ -4 +4\n" + + " - android:id=\"@+id/menu_settings\"\n" + + " + android:id=\"@+id/new_id_for_the_action_bar\"\n" + + "\n" + + "\n" + + "[ ] R.java - /testRefactor2/gen/com/example/refactoringtest/R.java\n" + + " @@ -19 +19\n" + + " - public static final int menu_settings=0x7f070003;\n" + + " + public static final int new_id_for_the_action_bar=0x7f070003;"); + } + + public void testRefactor3() throws Exception { + renameResource( + TEST_PROJECT, + "@+id/textView1", + true /*updateReferences*/, + "output", + + "CHANGES:\n" + + "-------\n" + + "[x] activity_main.xml - /testRefactor3/res/layout/activity_main.xml\n" + + " @@ -8 +8\n" + + " - android:id=\"@+id/textView1\"\n" + + " + android:id=\"@+id/output\"\n" + + " @@ -19 +19\n" + + " - android:layout_alignLeft=\"@+id/textView1\"\n" + + " - android:layout_below=\"@+id/textView1\"\n" + + " + android:layout_alignLeft=\"@+id/output\"\n" + + " + android:layout_below=\"@+id/output\"\n" + + "\n" + + "\n" + + "[x] MainActivity.java - /testRefactor3/src/com/example/refactoringtest/MainActivity.java\n" + + " @@ -14 +14\n" + + " - View view1 = findViewById(R.id.textView1);\n" + + " + View view1 = findViewById(R.id.output);\n" + + "\n" + + "\n" + + "[ ] R.java - /testRefactor3/gen/com/example/refactoringtest/R.java\n" + + " @@ -20 +20\n" + + " - public static final int textView1=0x7f070000;\n" + + " + public static final int output=0x7f070000;"); + } + + public void testRefactor4() throws Exception { + renameResource( + TEST_PROJECT, + // same as testRefactor3, but use @id rather than @+id even though @+id is in file + "@id/textView1", + true /*updateReferences*/, + "output", + + "CHANGES:\n" + + "-------\n" + + "[x] activity_main.xml - /testRefactor4/res/layout/activity_main.xml\n" + + " @@ -8 +8\n" + + " - android:id=\"@+id/textView1\"\n" + + " + android:id=\"@+id/output\"\n" + + " @@ -19 +19\n" + + " - android:layout_alignLeft=\"@+id/textView1\"\n" + + " - android:layout_below=\"@+id/textView1\"\n" + + " + android:layout_alignLeft=\"@+id/output\"\n" + + " + android:layout_below=\"@+id/output\"\n" + + "\n" + + "\n" + + "[x] MainActivity.java - /testRefactor4/src/com/example/refactoringtest/MainActivity.java\n" + + " @@ -14 +14\n" + + " - View view1 = findViewById(R.id.textView1);\n" + + " + View view1 = findViewById(R.id.output);\n" + + "\n" + + "\n" + + "[ ] R.java - /testRefactor4/gen/com/example/refactoringtest/R.java\n" + + " @@ -20 +20\n" + + " - public static final int textView1=0x7f070000;\n" + + " + public static final int output=0x7f070000;"); + } + + public void testRefactor5() throws Exception { + renameResource( + TEST_PROJECT, + "@layout/activity_main", + true /*updateReferences*/, + "newlayout", + + "CHANGES:\n" + + "-------\n" + + "[x] MainActivity.java - /testRefactor5/src/com/example/refactoringtest/MainActivity.java\n" + + " @@ -13 +13\n" + + " - setContentView(R.layout.activity_main);\n" + + " + setContentView(R.layout.newlayout);\n" + + "\n" + + "\n" + + "[ ] R.java - /testRefactor5/gen/com/example/refactoringtest/R.java\n" + + " @@ -23 +23\n" + + " - public static final int activity_main=0x7f030000;\n" + + " + public static final int newlayout=0x7f030000;\n" + + "\n" + + "\n" + + "[x] Rename 'testRefactor5/res/layout/activity_main.xml' to 'newlayout.xml'\n" + + "\n" + + "[x] Rename 'testRefactor5/res/layout-land/activity_main.xml' to 'newlayout.xml'"); + } + + public void testRefactor6() throws Exception { + renameResource( + TEST_PROJECT, + "@drawable/ic_launcher", + true /*updateReferences*/, + "newlauncher", + + "CHANGES:\n" + + "-------\n" + + "[ ] R.java - /testRefactor6/gen/com/example/refactoringtest/R.java\n" + + " @@ -14 +14\n" + + " - public static final int ic_launcher=0x7f020000;\n" + + " + public static final int newlauncher=0x7f020000;\n" + + "\n" + + "\n" + + "[x] Rename 'testRefactor6/res/drawable-xhdpi/ic_launcher.png' to 'newlauncher.png'\n" + + "\n" + + "[x] Rename 'testRefactor6/res/drawable-mdpi/ic_launcher.png' to 'newlauncher.png'\n" + + "\n" + + "[x] Rename 'testRefactor6/res/drawable-ldpi/ic_launcher.png' to 'newlauncher.png'\n" + + "\n" + + "[x] Rename 'testRefactor6/res/drawable-hdpi/ic_launcher.png' to 'newlauncher.png'\n" + + "\n" + + "[x] AndroidManifest.xml - /testRefactor6/AndroidManifest.xml\n" + + " @@ -12 +12\n" + + " - android:icon=\"@drawable/ic_launcher\"\n" + + " + android:icon=\"@drawable/newlauncher\""); + } + + public void testRefactor7() throws Exception { + // Test refactoring initiated on a file rename + IProject project = createProject(TEST_PROJECT); + IFile file = project.getFile("res/layout/activity_main.xml"); + renameResource( + project, + file, + true /*updateReferences*/, + "newlayout", + + "CHANGES:\n" + + "-------\n" + + "[x] MainActivity.java - /testRefactor7/src/com/example/refactoringtest/MainActivity.java\n" + + " @@ -13 +13\n" + + " - setContentView(R.layout.activity_main);\n" + + " + setContentView(R.layout.newlayout);\n" + + "\n" + + "\n" + + "[ ] R.java - /testRefactor7/gen/com/example/refactoringtest/R.java\n" + + " @@ -23 +23\n" + + " - public static final int activity_main=0x7f030000;\n" + + " + public static final int newlayout=0x7f030000;\n" + + "\n" + + "\n" + + "[x] Rename 'testRefactor7/res/layout-land/activity_main.xml' to 'newlayout.xml'\n" + + "\n" + + "[x] Rename 'testRefactor7/res/layout/activity_main.xml' to 'newlayout.xml'", + null); + } + + public void testRefactor8() throws Exception { + // Test refactoring initiated on a Java field rename + IProject project = createProject(TEST_PROJECT); + IJavaProject javaProject = BaseProjectHelper.getJavaProject(project); + assertNotNull(javaProject); + IType type = javaProject.findType("com.example.refactoringtest.R.layout"); + if (type == null || !type.exists()) { + type = javaProject.findType("com.example.refactoringtest.R$layout"); + System.out.println("Had to switch to $ notation"); + } + assertNotNull(type); + assertTrue(type.exists()); + IField field = type.getField("activity_main"); + assertNotNull(field); + assertTrue(field.exists()); + + renameResource( + project, + field, + true /*updateReferences*/, + "newlauncher", + + "CHANGES:\n" + + "-------\n" + + "[x] Rename 'testRefactor8/res/layout/activity_main.xml' to 'newlauncher.xml'\n" + + "\n" + + "[x] Rename 'testRefactor8/res/layout-land/activity_main.xml' to 'newlauncher.xml'\n" + + "\n" + + "[x] MainActivity.java - /testRefactor8/src/com/example/refactoringtest/MainActivity.java\n" + + " @@ -13 +13\n" + + " - setContentView(R.layout.activity_main);\n" + + " + setContentView(R.layout.newlauncher);\n" + + "\n" + + "\n" + + "[ ] R.java - /testRefactor8/gen/com/example/refactoringtest/R.java\n" + + " @@ -23 +23\n" + + " - public static final int activity_main=0x7f030000;\n" + + " + public static final int newlauncher=0x7f030000;", + null); + } + + public void testInvalidName() throws Exception { + renameResource( + TEST_PROJECT, + "@drawable/ic_launcher", + true /*updateReferences*/, + "Newlauncher", + + "", + "<ERROR\n" + + "\t\n" + + "ERROR: File-based resource names must start with a lowercase letter.\n" + + "Context: <Unspecified context>\n" + + "code: none\n" + + "Data: null\n" + + ">"); + } + + public void testRefactor9() throws Exception { + // same as testRefactor4, but not updating references + renameResource( + TEST_PROJECT, + "@id/textView1", + false /*updateReferences*/, + "output", + + "CHANGES:\n" + + "-------\n" + + "[x] activity_main.xml - /testRefactor9/res/layout/activity_main.xml\n" + + " @@ -8 +8\n" + + " - android:id=\"@+id/textView1\"\n" + + " + android:id=\"@+id/output\"\n" + + "\n" + + "\n" + + "[ ] R.java - /testRefactor9/gen/com/example/refactoringtest/R.java\n" + + " @@ -20 +20\n" + + " - public static final int textView1=0x7f070000;\n" + + " + public static final int output=0x7f070000;"); + } + + public void testRefactor10() throws Exception { + // Check updating tools: attributes + renameResource( + TEST_PROJECT, + "@layout/preview", + true /*updateReferences*/, + "newlayout", + + "CHANGES:\n" + + "-------\n" + + "[x] activity_main.xml - /testRefactor10/res/layout-land/activity_main.xml\n" + + " @@ -10 +10\n" + + " - tools:listitem=\"@layout/preview\" >\n" + + " + tools:listitem=\"@layout/newlayout\" >\n" + + " @@ -17 +17\n" + + " - tools:layout=\"@layout/preview\" />\n" + + " + tools:layout=\"@layout/newlayout\" />"); + } + + // ---- Test infrastructure ---- + + protected void renameResource( + @NonNull Object[] testData, + @NonNull Object resource, + boolean updateReferences, + @NonNull String newName, + @NonNull String expected) throws Exception { + renameResource(testData, resource, updateReferences, newName, expected, null); + } + + protected void renameResource( + @NonNull Object[] testData, + @NonNull Object resource, + boolean updateReferences, + @NonNull String newName, + @NonNull String expected, + @NonNull String expectedWarnings) throws Exception { + IProject project = createProject(testData); + renameResource(project, resource, updateReferences, newName, expected, expectedWarnings); + } + + protected void renameResource( + @NonNull IProject project, + @NonNull Object resource, + boolean updateReferences, + @NonNull String newName, + @NonNull String expected, + @NonNull String expectedWarnings) throws Exception { + RenameProcessor processor = null; + if (resource instanceof String) { + String url = (String) resource; + assert url.startsWith("@") : resource; + + ResourceUrl parsedUrl = ResourceUrl.parse(url); + assertNotNull(url, parsedUrl); + assert parsedUrl != null; // null analysis doesn't recognize assertNotNull + ResourceType type = parsedUrl.type; + String currentName = parsedUrl.name; + RenameResourceProcessor p; + p = new RenameResourceProcessor(project, type, currentName, newName); + p.setUpdateReferences(updateReferences); + processor = p; + } else if (resource instanceof IResource) { + IResource r = (IResource) resource; + org.eclipse.ltk.internal.core.refactoring.resource.RenameResourceProcessor p; + p = new org.eclipse.ltk.internal.core.refactoring.resource.RenameResourceProcessor(r); + String fileName = r.getName(); + int dot = fileName.indexOf('.'); + String extension = (dot != -1) ? fileName.substring(dot) : ""; + p.setNewResourceName(newName + extension); + p.setUpdateReferences(updateReferences); + processor = p; + } else if (resource instanceof IField) { + RenameFieldProcessor p = new RenameFieldProcessor((IField) resource); + p.setNewElementName(newName); + p.setUpdateReferences(updateReferences); + processor = p; + } else { + fail("Unsupported resource element in tests: " + resource); + } + + assertNotNull(processor); + + RenameRefactoring refactoring = new RenameRefactoring(processor); + checkRefactoring(refactoring, expected, expectedWarnings); + } +}
\ No newline at end of file diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/refactorings/renamepackage/ApplicationPackageNameRefactoringTest.java b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/refactorings/renamepackage/ApplicationPackageNameRefactoringTest.java new file mode 100644 index 000000000..0ac034430 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/refactorings/renamepackage/ApplicationPackageNameRefactoringTest.java @@ -0,0 +1,128 @@ +/* + * Copyright (C) 2012 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.refactorings.renamepackage; + +import com.android.annotations.NonNull; +import com.android.ide.eclipse.adt.internal.editors.manifest.ManifestInfo; +import com.android.ide.eclipse.adt.internal.refactorings.core.RefactoringTestBase; + +import org.eclipse.core.resources.IProject; +import org.eclipse.jdt.core.dom.AST; +import org.eclipse.jdt.core.dom.Name; + +@SuppressWarnings("javadoc") +public class ApplicationPackageNameRefactoringTest extends RefactoringTestBase { + public void testRefactor1() throws Exception { + renamePackage( + TEST_PROJECT, + "my.pkg.name", + + "CHANGES:\n" + + "-------\n" + + "[x] MainActivity.java - /testRefactor1/src/com/example/refactoringtest/MainActivity.java\n" + + " @@ -7 +7\n" + + " + import my.pkg.name.R;\n" + + "\n" + + "\n" + + "[x] Make Manifest edits - /testRefactor1/AndroidManifest.xml\n" + + " @@ -3 +3\n" + + " - package=\"com.example.refactoringtest\"\n" + + " + package=\"my.pkg.name\"\n" + + " @@ -25 +25\n" + + " - android:name=\".MainActivity2\"\n" + + " + android:name=\"com.example.refactoringtest.MainActivity2\""); + } + + public void testRefactor2() throws Exception { + // Tests custom view handling + renamePackage( + TEST_PROJECT2, + "my.pkg.name", + + "CHANGES:\n" + + "-------\n" + + "[x] MainActivity.java - /testRefactor2/src/com/example/refactoringtest/MainActivity.java\n" + + " @@ -7 +7\n" + + " + import my.pkg.name.R;\n" + + "\n" + + "\n" + + "[x] Make Manifest edits - /testRefactor2/AndroidManifest.xml\n" + + " @@ -3 +3\n" + + " - package=\"com.example.refactoringtest\"\n" + + " + package=\"my.pkg.name\"\n" + + " @@ -25 +25\n" + + " - android:name=\".MainActivity2\"\n" + + " + android:name=\"com.example.refactoringtest.MainActivity2\""); + } + + public void testRefactor3() throws Exception { + // Tests BuildConfig imports and updates + renamePackage( + TEST_PROJECT3, + "my.pkg.name", + + "CHANGES:\n" + + "-------\n" + + "[x] MoreCode.java - /testRefactor3/src/com/example/refactoringtest/subpkg/MoreCode.java\n" + + " @@ -7 +7\n" + + " - import com.example.refactoringtest.BuildConfig;\n" + + " - import com.example.refactoringtest.Manifest;\n" + + " - import com.example.refactoringtest.R;\n" + + " + import my.pkg.name.BuildConfig;\n" + + " + import my.pkg.name.Manifest;\n" + + " + import my.pkg.name.R;\n" + + "\n" + + "\n" + + "[x] MainActivity.java - /testRefactor3/src/com/example/refactoringtest/MainActivity.java\n" + + " @@ -7 +7\n" + + " + import my.pkg.name.R;\n" + + "\n" + + "\n" + + "[x] Make Manifest edits - /testRefactor3/AndroidManifest.xml\n" + + " @@ -3 +3\n" + + " - package=\"com.example.refactoringtest\"\n" + + " + package=\"my.pkg.name\"\n" + + " @@ -25 +25\n" + + " - android:name=\".MainActivity2\"\n" + + " + android:name=\"com.example.refactoringtest.MainActivity2\""); + } + + // ---- Test infrastructure ---- + + protected void renamePackage( + @NonNull Object[] testData, + @NonNull String newName, + @NonNull String expected) throws Exception { + IProject project = createProject(testData); + renamePackage(project, newName, expected); + } + + protected void renamePackage( + @NonNull IProject project, + @NonNull String newName, + @NonNull String expected) throws Exception { + ManifestInfo info = ManifestInfo.get(project); + String currentPackage = info.getPackage(); + assertNotNull(currentPackage); + + final AST astValidator = AST.newAST(AST.JLS3); + Name oldPackageName = astValidator.newName(currentPackage); + Name newPackageName = astValidator.newName(newName); + ApplicationPackageNameRefactoring refactoring = + new ApplicationPackageNameRefactoring(project, oldPackageName, newPackageName); + checkRefactoring(refactoring, expected); + } +} diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/wizards/exportgradle/ExportGradleTest.java b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/wizards/exportgradle/ExportGradleTest.java new file mode 100644 index 000000000..f5cc58bcf --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/wizards/exportgradle/ExportGradleTest.java @@ -0,0 +1,303 @@ +/* + * Copyright (C) 2013 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.wizards.exportgradle; + +import static com.android.sdklib.internal.project.ProjectProperties.PROPERTY_LIBRARY; + +import com.android.SdkConstants; +import com.android.ide.eclipse.adt.AdtPlugin; +import com.android.ide.eclipse.adt.AdtUtils; +import com.android.ide.eclipse.adt.internal.editors.layout.refactoring.AdtProjectTest; +import com.android.ide.eclipse.adt.internal.project.BaseProjectHelper; +import com.android.ide.eclipse.adt.internal.sdk.ProjectState; +import com.android.ide.eclipse.adt.internal.sdk.Sdk; +import com.android.ide.eclipse.adt.internal.wizards.newproject.NewProjectCreator; +import com.android.ide.eclipse.adt.internal.wizards.newproject.NewProjectWizardState; +import com.android.ide.eclipse.adt.internal.wizards.newproject.NewProjectWizardState.Mode; +import com.android.sdklib.internal.project.ProjectPropertiesWorkingCopy; +import com.google.common.base.Charsets; +import com.google.common.io.Files; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.QualifiedName; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.jdt.core.IJavaProject; +import org.eclipse.jface.operation.IRunnableContext; +import org.eclipse.jface.operation.IRunnableWithProgress; + +import java.io.File; +import java.lang.reflect.InvocationTargetException; +import java.util.Collections; + +public class ExportGradleTest extends AdtProjectTest { + private QualifiedName ERROR_KEY = new QualifiedName(AdtPlugin.PLUGIN_ID, "JobErrorKey"); + private Throwable mLastThrown; + + @Override + public void setUp() throws Exception { + super.setUp(); + mLastThrown = null; + } + + @Override + protected boolean testCaseNeedsUniqueProject() { + return true; + } + + public void testSimpleAndroidApp() throws Throwable { + IProject project = getProject("simple-app"); + final IJavaProject javaProject = BaseProjectHelper.getJavaProject(project); + + final ProjectSetupBuilder builder = new ProjectSetupBuilder(); + builder.setProject(Collections.singletonList(javaProject)); + + Job job = new Job("Validate project") { + @Override + protected IStatus run(IProgressMonitor monitor) { + try { + BuildFileCreator.createBuildFiles(builder, null, monitor); + File buildfile = new File(javaProject.getResource().getLocation().toString(), + BuildFileCreator.BUILD_FILE); + assertTrue(buildfile.exists()); + String contents = Files.toString(buildfile, Charsets.UTF_8); + String expectedContents = + "buildscript {\n" + + " repositories {\n" + + " " + BuildFileCreator.MAVEN_REPOSITORY + "\n" + + " }\n" + + " dependencies {\n" + + " " + BuildFileCreator.PLUGIN_CLASSPATH + "\n" + + " }\n" + + "}\n" + + "apply plugin: 'android'\n" + + "\n" + + "dependencies {\n" + + "}\n" + + "\n" + + "android {\n" + + " compileSdkVersion 16\n" + + " buildToolsVersion \"16\"\n" + + "\n" + + " defaultConfig {\n" + + " minSdkVersion 1\n" + + " targetSdkVersion 1\n" + + " }\n" + + " sourceSets {\n" + + " main {\n" + + " manifest.srcFile 'AndroidManifest.xml'\n" + + " java.srcDirs = ['src']\n" + + " resources.srcDirs = ['src']\n" + + " aidl.srcDirs = ['src']\n" + + " renderscript.srcDirs = ['src']\n" + + " res.srcDirs = ['res']\n" + + " assets.srcDirs = ['assets']\n" + + " }\n" + + " instrumentTest.setRoot('tests')\n" + + " }\n" + + "}"; + + assertEqualsWhitespaceInsensitive(expectedContents, contents); + } catch (Throwable t) { + mLastThrown = t; + } + return null; + } + }; + job.schedule(1000); + job.join(); + Object property = job.getProperty(ERROR_KEY); + assertNull(property); + if (mLastThrown != null) { + throw mLastThrown; + } + } + + public void testSimpleAndroidLib() throws Throwable { + final IProject project = getProject("simple-library"); + ProjectState projectState = Sdk.getProjectState(project.getProject()); + ProjectPropertiesWorkingCopy propertiesWorkingCopy = projectState.getProperties().makeWorkingCopy(); + propertiesWorkingCopy.setProperty(PROPERTY_LIBRARY, "true"); + propertiesWorkingCopy.save(); + IResource projectProp = project.findMember(SdkConstants.FN_PROJECT_PROPERTIES); + if (projectProp != null) { + projectProp.refreshLocal(IResource.DEPTH_ZERO, new NullProgressMonitor()); + } + + Job job = new Job("Validate project") { + @Override + protected IStatus run(IProgressMonitor monitor) { + try { + IJavaProject javaProject = BaseProjectHelper.getJavaProject(project); + + final ProjectSetupBuilder builder = new ProjectSetupBuilder(); + builder.setProject(Collections.singletonList(javaProject)); + + BuildFileCreator.createBuildFiles(builder, null, monitor); + File buildfile = new File(javaProject.getResource().getLocation().toString(), + BuildFileCreator.BUILD_FILE); + assertTrue(buildfile.exists()); + String contents = Files.toString(buildfile, Charsets.UTF_8); + String expectedContents = + "buildscript {\n" + + " repositories {\n" + + " " + BuildFileCreator.MAVEN_REPOSITORY + "\n" + + " }\n" + + " dependencies {\n" + + " " + BuildFileCreator.PLUGIN_CLASSPATH + "\n" + + " }\n" + + "}\n" + + "apply plugin: 'android-library'\n" + + "\n" + + "dependencies {\n" + + "}\n" + + "\n" + + "android {\n" + + " compileSdkVersion 16\n" + + " buildToolsVersion \"16\"\n" + + "\n" + + " defaultConfig {\n" + + " minSdkVersion 1\n" + + " targetSdkVersion 1\n" + + " }\n" + + " sourceSets {\n" + + " main {\n" + + " manifest.srcFile 'AndroidManifest.xml'\n" + + " java.srcDirs = ['src']\n" + + " resources.srcDirs = ['src']\n" + + " aidl.srcDirs = ['src']\n" + + " renderscript.srcDirs = ['src']\n" + + " res.srcDirs = ['res']\n" + + " assets.srcDirs = ['assets']\n" + + " }\n" + + " instrumentTest.setRoot('tests')\n" + + " }\n" + + "}"; + + assertEqualsWhitespaceInsensitive(expectedContents, contents); + } catch (Throwable t) { + mLastThrown = t; + } + return null; + } + }; + job.schedule(1000); + job.join(); + Object property = job.getProperty(ERROR_KEY); + assertNull(property); + if (mLastThrown != null) { + throw mLastThrown; + } + } + + public void testPlainJavaProject() throws Throwable { + IProject project = getJavaProject("simple-java"); + final IJavaProject javaProject = BaseProjectHelper.getJavaProject(project); + + final ProjectSetupBuilder builder = new ProjectSetupBuilder(); + builder.setProject(Collections.singletonList(javaProject)); + + BuildFileCreator.createBuildFiles(builder, null, null); + Job job = new Job("Validate project") { + @Override + protected IStatus run(IProgressMonitor monitor) { + try { + File buildfile = new File(javaProject.getResource().getLocation().toString(), "build.gradle"); + assertTrue(buildfile.exists()); + String contents = Files.toString(buildfile, Charsets.UTF_8); + String expectedContents = + "apply plugin: 'java'\n" + + "sourceSets {\n" + + " main.java.srcDirs = ['src']\n" + + "}"; + + assertEqualsWhitespaceInsensitive(expectedContents, contents); + } catch (Throwable t) { + mLastThrown = t; + } + return null; + } + }; + job.schedule(1000); + job.join(); + Object property = job.getProperty(ERROR_KEY); + assertNull(property); + if (mLastThrown != null) { + throw mLastThrown; + } + } + + protected IProject getProject(String projectName) { + IProject project = createProject(projectName); + assertNotNull(project); + if (!testCaseNeedsUniqueProject() && !testNeedsUniqueProject()) { + addCleanupDir(AdtUtils.getAbsolutePath(project).toFile()); + } + addCleanupDir(project.getFullPath().toFile()); + return project; + } + + protected IProject getJavaProject(String projectName) { + IProject project = createJavaProject(projectName); + assertNotNull(project); + if (!testCaseNeedsUniqueProject() && !testNeedsUniqueProject()) { + addCleanupDir(AdtUtils.getAbsolutePath(project).toFile()); + } + addCleanupDir(project.getFullPath().toFile()); + return project; + } + + protected IProject createJavaProject(String name) { + IRunnableContext context = new IRunnableContext() { + @Override + public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable) + throws InvocationTargetException, InterruptedException { + runnable.run(new NullProgressMonitor()); + } + }; + NewProjectWizardState state = new NewProjectWizardState(Mode.ANY); + state.projectName = name; + state.packageName = TEST_PROJECT_PACKAGE; + state.activityName = name; + state.applicationName = name; + state.createActivity = false; + state.useDefaultLocation = true; + if (getMinSdk() != -1) { + state.minSdk = Integer.toString(getMinSdk()); + } + + NewProjectCreator creator = new NewProjectCreator(state, context); + creator.createJavaProjects(); + return validateProjectExists(name); + } + + /** + * Compares two strings, disregarding whitespace. This makes the test less brittle with respect + * to insignificant changes. + */ + protected void assertEqualsWhitespaceInsensitive(String a, String b) { + a = stripWhitespace(a); + b = stripWhitespace(b); + assertEquals("Expected:\n" + a + "\nbut was:\n" + b + "\n\n", a, b); + } + + protected String stripWhitespace(String s) { + return s.replaceAll("\\s",""); + } +}
\ No newline at end of file diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/wizards/templates/TemplateHandlerTest.java b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/wizards/templates/TemplateHandlerTest.java new file mode 100644 index 000000000..9d3bc60c6 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/wizards/templates/TemplateHandlerTest.java @@ -0,0 +1,901 @@ +/* + * Copyright (C) 2012 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.wizards.templates; + +import static com.android.SdkConstants.CURRENT_PLATFORM; +import static com.android.SdkConstants.FD_TOOLS; +import static com.android.SdkConstants.PLATFORM_WINDOWS; +import static com.android.ide.eclipse.adt.internal.wizards.templates.NewProjectWizard.ATTR_MIN_API; +import static com.android.ide.eclipse.adt.internal.wizards.templates.NewProjectWizard.ATTR_MIN_BUILD_API; +import static com.android.ide.eclipse.adt.internal.wizards.templates.TemplateHandler.ATTR_ID; + +import com.android.annotations.NonNull; +import com.android.annotations.Nullable; +import com.android.sdklib.SdkVersionInfo; +import com.android.ide.eclipse.adt.AdtPlugin; +import com.android.ide.eclipse.adt.AdtUtils; +import com.android.ide.eclipse.adt.internal.lint.EclipseLintClient; +import com.android.ide.eclipse.adt.internal.preferences.AdtPrefs; +import com.android.ide.eclipse.adt.internal.sdk.Sdk; +import com.android.ide.eclipse.tests.SdkLoadingTestCase; +import com.android.sdklib.IAndroidTarget; +import com.android.utils.GrabProcessOutput; +import com.android.utils.GrabProcessOutput.IProcessOutput; +import com.android.utils.GrabProcessOutput.Wait; +import com.android.tools.lint.checks.ManifestDetector; +import com.android.tools.lint.checks.SecurityDetector; +import com.android.tools.lint.client.api.Configuration; +import com.android.tools.lint.client.api.DefaultConfiguration; +import com.android.tools.lint.client.api.JavaParser; +import com.android.tools.lint.client.api.LintClient; +import com.android.tools.lint.client.api.LintDriver; +import com.android.tools.lint.client.api.XmlParser; +import com.android.tools.lint.detector.api.Category; +import com.android.tools.lint.detector.api.Context; +import com.android.tools.lint.detector.api.Issue; +import com.android.tools.lint.detector.api.Location; +import com.android.tools.lint.detector.api.Project; +import com.android.tools.lint.detector.api.Scope; +import com.android.tools.lint.detector.api.Severity; +import com.android.tools.lint.detector.api.TextFormat; +import com.google.common.base.Charsets; +import com.google.common.base.Stopwatch; +import com.google.common.collect.Lists; +import com.google.common.collect.Sets; +import com.google.common.io.Files; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.QualifiedName; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.ltk.core.refactoring.Change; +import org.eclipse.ltk.core.refactoring.CompositeChange; +import org.w3c.dom.Element; + +import java.io.File; +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Set; + +/** + * Unit tests for template instantiation. + * <p> + * Note: This test can take multiple hours to run! + * + * <p> + * TODO: Test all permutations of variables (it currently just varies one at a time with the + * rest of the defaults) + * TODO: Test trying to change strings arguments (currently just varies enums and booleans) + * TODO: Test adding multiple instances of the templates (to look for resource conflicts) + */ +@SuppressWarnings("javadoc") +public class TemplateHandlerTest extends SdkLoadingTestCase { + /** + * Flag used to quickly check each template once (for one version), to get + * quicker feedback on whether something is broken instead of waiting for + * all the versions for each template first + */ + private static final boolean TEST_FEWER_API_VERSIONS = true; + private static final boolean TEST_JUST_ONE_MIN_SDK = false; + private static final boolean TEST_JUST_ONE_BUILD_TARGET = true; + private static final boolean TEST_JUST_ONE_TARGET_SDK_VERSION = true; + private QualifiedName ERROR_KEY = new QualifiedName(AdtPlugin.PLUGIN_ID, "JobErrorKey"); + private static int sCount = 0; + /** + * If true, check this template with all the interesting ( + * {@link #isInterestingApiLevel(int)}) api versions + */ + private boolean mApiSensitiveTemplate; + /** + * Set of templates already tested with separate unit test; remainder is + * checked in {@link #testCreateRemainingProjects()} + */ + private static final Set<File> sProjectTestedSeparately = Sets.newHashSet(); + /** + * Set of templates already tested with separate unit test; remainder is + * checked in {@link #testCreateRemainingTemplates()} + */ + private static final Set<File> sTemplateTestedSeparately = Sets.newHashSet(); + + @Override + protected void setUp() throws Exception { + super.setUp(); + mApiSensitiveTemplate = true; + } + + /** + * Is the given api level interesting for testing purposes? This is used to + * skip gaps, such that we for example only check say api 8, 9, 11, 14, etc + * -- versions where the <b>templates</b> are doing conditional changes. To + * be EXTRA comprehensive, occasionally try returning true unconditionally + * here to test absolutely everything. + */ + private boolean isInterestingApiLevel(int api) { + // For templates that aren't API sensitive, only test with API = 16 + if (!mApiSensitiveTemplate) { + return api == 16; + } + + switch (api) { + case 1: + case 8: + return true; + case 11: + return true; + case 14: + return true; + case 9: + case 16: + return !TEST_FEWER_API_VERSIONS; + default: + return false; + } + } + + public void testNewBlankProject() throws Exception { + Stopwatch stopwatch = Stopwatch.createUnstarted(); + stopwatch.start(); + checkProjectWithActivity(null); + stopwatch.stop(); + System.out.println("Checked blank project successfully in " + + stopwatch.toString()); + } + + public void testNewBlankActivity() throws Exception { + checkCreateTemplate("activities", "BlankActivity"); + } + + public void testBlankActivityInProject() throws Exception { + checkCreateActivityInProject("BlankActivity"); + } + + public void testNewMasterDetailFlow() throws Exception { + checkCreateTemplate("activities", "MasterDetailFlow"); + } + + public void testMasterDetailFlowInProject() throws Exception { + checkCreateActivityInProject("MasterDetailFlow"); + } + + public void testNewFullscreen() throws Exception { + checkCreateTemplate("activities", "FullscreenActivity"); + } + + public void testFullscreenInProject() throws Exception { + checkCreateActivityInProject("FullscreenActivity"); + } + + public void testNewLoginActivity() throws Exception { + checkCreateTemplate("activities", "LoginActivity"); + } + + public void testLoginActivityInProject() throws Exception { + checkCreateActivityInProject("MasterDetailFlow"); + } + + public void testNewSettingsActivity() throws Exception { + checkCreateTemplate("activities", "SettingsActivity"); + } + + public void testSettingsActivityInProject() throws Exception { + checkCreateActivityInProject("SettingsActivity"); + } + + public void testNewBroadcastReceiver() throws Exception { + // No need to try this template with multiple platforms, one is adequate + mApiSensitiveTemplate = false; + checkCreateTemplate("other", "BroadcastReceiver"); + } + + public void testNewContentProvider() throws Exception { + mApiSensitiveTemplate = false; + checkCreateTemplate("other", "ContentProvider"); + } + + public void testNewCustomView() throws Exception { + mApiSensitiveTemplate = false; + checkCreateTemplate("other", "CustomView"); + } + + public void testNewService() throws Exception { + mApiSensitiveTemplate = false; + checkCreateTemplate("other", "Service"); + } + + public void testCreateRemainingTemplates() throws Exception { + sCount = 0; + long begin = System.currentTimeMillis(); + TemplateManager manager = new TemplateManager(); + List<File> other = manager.getTemplates("other"); + for (File templateFile : other) { + if (sTemplateTestedSeparately.contains(templateFile)) { + continue; + } + checkTemplate(templateFile); + } + // Also try creating templates, not as part of creating a project + List<File> activities = manager.getTemplates("activities"); + for (File templateFile : activities) { + if (sTemplateTestedSeparately.contains(templateFile)) { + continue; + } + checkTemplate(templateFile); + } + long end = System.currentTimeMillis(); + System.out.println("Successfully checked " + sCount + " template permutations in " + + ((end - begin) / (1000 * 60)) + " minutes"); + } + + public void testCreateRemainingProjects() throws Exception { + sCount = 0; + long begin = System.currentTimeMillis(); + TemplateManager manager = new TemplateManager(); + List<File> templates = manager.getTemplates("activities"); + for (File activityFile : templates) { + if (sTemplateTestedSeparately.contains(activityFile)) { + continue; + } + checkProjectWithActivity(activityFile.getName()); + } + long end = System.currentTimeMillis(); + System.out.println("Successfully checked " + sCount + " project permutations in " + + ((end - begin) / (1000 * 60)) + " minutes"); + } + + // ---- Test support code below ---- + + private void checkCreateActivityInProject(String activityName) throws Exception { + Stopwatch stopwatch = Stopwatch.createUnstarted(); + stopwatch.start(); + File templateFile = findTemplate("activities", activityName); + sProjectTestedSeparately.add(templateFile); + checkProjectWithActivity(templateFile.getName()); + stopwatch.stop(); + System.out.println("Checked " + templateFile.getName() + " successfully in " + + stopwatch.toString()); + } + + private void checkCreateTemplate(String category, String name) throws Exception { + Stopwatch stopwatch = Stopwatch.createUnstarted(); + stopwatch.start(); + File templateFile = findTemplate(category, name); + assertNotNull(templateFile); + sTemplateTestedSeparately.add(templateFile); + checkTemplate(templateFile); + stopwatch.stop(); + System.out.println("Checked " + templateFile.getName() + " successfully in " + + stopwatch.toString()); + } + + private static File findTemplate(String category, String name) { + File templateRootFolder = TemplateManager.getTemplateRootFolder(); + assertNotNull(templateRootFolder); + File file = new File(templateRootFolder, category + File.separator + name); + assertTrue(file.getPath(), file.exists()); + return file; + } + + private void checkTemplate(File templateFile) throws Exception { + NewProjectWizardState values = new NewProjectWizardState(); + values.applicationName = "My Application"; + values.packageName = "my.pkg2"; + + values.isLibrary = false; + values.createIcon = false; + values.useDefaultLocation = true; + values.createActivity = false; + + String projectNameBase = "MyTemplateProject_" + templateFile.getName(); + values.projectName = projectNameBase; + values.createActivity = false; + + // Create the new template + + NewTemplateWizardState state = new NewTemplateWizardState(); + state.setTemplateLocation(templateFile); + state.minSdkLevel = values.minSdkLevel; + + // Iterate over all (valid) combinations of build target, minSdk and targetSdk + IAndroidTarget[] targets = Sdk.getCurrent().getTargets(); + for (int i = targets.length - 1; i >= 0; i--) { + IAndroidTarget target = targets[i]; + if (!target.isPlatform()) { + continue; + } + if (!isInterestingApiLevel(target.getVersion().getApiLevel())) { + continue; + } + + for (int minSdk = 1; + minSdk <= SdkVersionInfo.HIGHEST_KNOWN_API; + minSdk++) { + // Don't bother checking *every* single minSdk, just pick some interesting ones + if (!isInterestingApiLevel(minSdk)) { + continue; + } + + for (int targetSdk = minSdk; + targetSdk <= SdkVersionInfo.HIGHEST_KNOWN_API; + targetSdk++) { + if (!isInterestingApiLevel(targetSdk)) { + continue; + } + + // Make sure this template is supported with these versions + IStatus status = values.template.validateTemplate( + minSdk, target.getVersion().getApiLevel()); + if (status != null && !status.isOK()) { + continue; + } + + // Also make sure activity is enabled for these versions + status = state.getTemplateHandler().validateTemplate( + minSdk, target.getVersion().getApiLevel()); + if (status != null && !status.isOK()) { + continue; + } + + // Iterate over all new new project templates + + // should I try all options of theme with all platforms? + // or just try all platforms, with one setting for each? + // doesn't seem like I need to multiply + // just pick the best setting that applies instead for each platform + List<Parameter> parameters = values.template.getTemplate().getParameters(); + projectParameters: + for (Parameter parameter : parameters) { + List<Element> options = parameter.getOptions(); + if (parameter.type == Parameter.Type.ENUM) { + for (Element element : options) { + Option option = Option.get(element); + String optionId = option.id; + int optionMinSdk = option.minSdk; + int optionMinBuildApi = option.minBuild; + if (optionMinSdk <= minSdk && + optionMinBuildApi <= target.getVersion().getApiLevel()) { + values.parameters.put(parameter.id, optionId); + if (parameter.id.equals("baseTheme")) { + String base = projectNameBase + "_min_" + minSdk + + "_target_" + targetSdk + + "_build_" + target.getVersion().getApiLevel() + + "_theme_" + optionId; + System.out.println("checking base " + base); + + checkApiTarget(minSdk, targetSdk, target, values, base, + state); + break projectParameters; + } + } + } + } + } + + if (TEST_JUST_ONE_TARGET_SDK_VERSION) { + break; + } + } + + if (TEST_JUST_ONE_MIN_SDK) { + break; + } + } + + if (TEST_JUST_ONE_BUILD_TARGET) { + break; + } + } + } + + private void checkProjectWithActivity(String activity) throws Exception { + NewProjectWizardState values = new NewProjectWizardState(); + values.applicationName = "My Application"; + values.packageName = "my.pkg"; + + values.isLibrary = false; + values.createIcon = false; + values.useDefaultLocation = true; + + // These are basically unused; passed as defaults + values.activityName = activity == null ? "Blank" : activity; + values.activityTitle = "My Activity Title"; + + String projectNameBase = "MyProject_" + values.activityName; + values.projectName = projectNameBase; + + values.createActivity = activity != null; + NewTemplateWizardState activityValues = values.activityValues; + assertNotNull(activityValues); + activityValues.minSdkLevel = values.minSdkLevel; + + + // Iterate over all (valid) combinations of build target, minSdk and targetSdk + IAndroidTarget[] targets = Sdk.getCurrent().getTargets(); + for (int i = targets.length - 1; i >= 0; i--) { + IAndroidTarget target = targets[i]; + if (!target.isPlatform()) { + continue; + } + if (!isInterestingApiLevel(target.getVersion().getApiLevel())) { + continue; + } + + for (int minSdk = 1; + minSdk <= SdkVersionInfo.HIGHEST_KNOWN_API; + minSdk++) { + // Don't bother checking *every* single minSdk, just pick some interesting ones + if (!isInterestingApiLevel(minSdk)) { + continue; + } + + for (int targetSdk = minSdk; + targetSdk <= SdkVersionInfo.HIGHEST_KNOWN_API; + targetSdk++) { + if (!isInterestingApiLevel(targetSdk)) { + continue; + } + + // Make sure this template is supported with these versions + IStatus status = values.template.validateTemplate( + values.minSdkLevel, values.getBuildApi()); + if (status != null && !status.isOK()) { + continue; + } + + // Also make sure activity is enabled for these versions + status = values.activityValues.getTemplateHandler().validateTemplate( + values.minSdkLevel, values.getBuildApi()); + if (status != null && !status.isOK()) { + continue; + } + + // Iterate over all new new project templates + + // should I try all options of theme with all platforms? + // or just try all platforms, with one setting for each? + // doesn't seem like I need to multiply + // just pick the best setting that applies instead for each platform + List<Parameter> parameters = values.template.getTemplate().getParameters(); + for (Parameter parameter : parameters) { + List<Element> options = parameter.getOptions(); + if (parameter.type == Parameter.Type.ENUM) { + for (Element element : options) { + Option option = Option.get(element); + String optionId = option.id; + int optionMinSdk = option.minSdk; + int optionMinBuildApi = option.minBuild; + if (optionMinSdk <= minSdk && + optionMinBuildApi <= target.getVersion().getApiLevel()) { + values.parameters.put(parameter.id, optionId); + if (parameter.id.equals("baseTheme")) { + String base = projectNameBase + "_min_" + minSdk + + "_target_" + targetSdk + + "_build_" + target.getVersion().getApiLevel() + + "_theme_" + optionId; + System.out.println("checking base " + base); + + checkApiTarget(minSdk, targetSdk, target, values, base, + null); + + } + } + } + } + } + + if (TEST_JUST_ONE_TARGET_SDK_VERSION) { + break; + } + } + + if (TEST_JUST_ONE_MIN_SDK) { + break; + } + } + + if (TEST_JUST_ONE_BUILD_TARGET) { + break; + } + } + } + + private void checkApiTarget( + int minSdk, + int targetSdk, + @NonNull IAndroidTarget target, + @NonNull NewProjectWizardState projectValues, + @NonNull String projectNameBase, + @Nullable NewTemplateWizardState templateValues) + throws Exception { + NewTemplateWizardState values = + projectValues.createActivity ? projectValues.activityValues : templateValues; + + projectValues.minSdk = Integer.toString(minSdk); + projectValues.minSdkLevel = minSdk; + projectValues.targetSdkLevel = targetSdk; + projectValues.target = target; + + if (values == null) { + checkProject(projectValues, templateValues); + return; + } + + // Next check all other parameters, cycling through booleans and enums. + TemplateHandler templateHandler = values.getTemplateHandler(); + TemplateMetadata template = templateHandler.getTemplate(); + assertNotNull(template); + List<Parameter> parameters = template.getParameters(); + + if (!projectValues.createActivity) { + for (Parameter parameter : parameters) { + values.parameters.put(parameter.id, parameter.value); + } + } + + for (Parameter parameter : parameters) { + if (parameter.type == Parameter.Type.SEPARATOR + || parameter.type == Parameter.Type.STRING) { + // TODO: Consider whether we should attempt some strings here + continue; + } + + // The initial (default value); revert to this one after cycling, + Object initial = values.parameters.get(parameter.id); + + if (parameter.type == Parameter.Type.ENUM) { + List<Element> options = parameter.getOptions(); + for (Element element : options) { + Option option = Option.get(element); + String optionId = option.id; + int optionMinSdk = option.minSdk; + int optionMinBuildApi = option.minBuild; + if (projectValues.minSdkLevel >= optionMinSdk && + projectValues.getBuildApi() >= optionMinBuildApi) { + values.parameters.put(parameter.id, optionId); + projectValues.projectName = projectNameBase + "_" + parameter.id + + "_" + optionId; + checkProject(projectValues, templateValues); + } + } + } else { + assert parameter.type == Parameter.Type.BOOLEAN; + if (parameter.id.equals("isLauncher") && projectValues.createActivity) { + // Skipping this one: always true when launched from new project + continue; + } + boolean value = false; + values.parameters.put(parameter.id, value); + projectValues.projectName = projectNameBase + "_" + parameter.id + + "_" + value; + checkProject(projectValues, templateValues); + + value = true; + values.parameters.put(parameter.id, value); + projectValues.projectName = projectNameBase + "_" + parameter.id + + "_" + value; + checkProject(projectValues, templateValues); + } + + values.parameters.put(parameter.id, initial); + } + } + + private final class OutputGrabber implements IProcessOutput { + private final List<String> output = Lists.newArrayList(); + private final List<String> error = Lists.newArrayList(); + + @Override + public void out(@Nullable String line) { + if (line != null) { + output.add(line); + } + } + + @Override + public void err(@Nullable String line) { + if (line != null) { + error.add(line); + } + } + + @NonNull + private List<String> getOutput() { + return output; + } + + @NonNull + private List<String> getError() { + return error; + } + } + + private static class Option { + private String id; + private int minSdk; + private int minBuild; + + public Option(String id, int minSdk, int minBuild) { + this.id = id; + this.minSdk = minSdk; + this.minBuild = minBuild; + } + + private static Option get(Element option) { + String optionId = option.getAttribute(ATTR_ID); + String minApiString = option.getAttribute(ATTR_MIN_API); + int optionMinSdk = 1; + if (minApiString != null && !minApiString.isEmpty()) { + try { + optionMinSdk = Integer.parseInt(minApiString); + } catch (NumberFormatException nufe) { + // Templates aren't allowed to contain codenames, should + // always be an integer + AdtPlugin.log(nufe, null); + optionMinSdk = 1; + } + } + String minBuildApiString = option.getAttribute(ATTR_MIN_BUILD_API); + int optionMinBuildApi = 1; + if (minBuildApiString != null && !minBuildApiString.isEmpty()) { + try { + optionMinBuildApi = Integer.parseInt(minBuildApiString); + } catch (NumberFormatException nufe) { + // Templates aren't allowed to contain codenames, should + // always be an integer + AdtPlugin.log(nufe, null); + optionMinBuildApi = 1; + } + } + + + return new Option(optionId, optionMinSdk, optionMinBuildApi); + } + } + + private void checkProject( + @NonNull NewProjectWizardState projectValues, + @Nullable NewTemplateWizardState templateValues) throws Exception { + NewTemplateWizardState values = + projectValues.createActivity ? projectValues.activityValues : templateValues; + if (values != null) { // if not, creating blank project + // Validate that a template is only being used in a context it is compatible with! + IStatus status = values.getTemplateHandler().validateTemplate( + projectValues.minSdkLevel, projectValues.getBuildApi()); + if (status != null && !status.isOK()) { + fail(status.toString()); + } + } + + assertNotNull(projectValues.projectName); + projectValues.projectName = AdtUtils.getUniqueProjectName(projectValues.projectName, ""); + IPath workspace = Platform.getLocation(); + String projectLocation = workspace.append(projectValues.projectName).toOSString(); + projectValues.projectLocation = projectLocation; + + // Create project with the given parameter map + final IProject project = createProject(projectValues); + assertNotNull(project); + + if (templateValues != null) { + templateValues.project = project; + List<Change> changes = templateValues.computeChanges(); + if (!changes.isEmpty()) { + try { + CompositeChange composite = new CompositeChange("", + changes.toArray(new Change[changes.size()])); + composite.perform(new NullProgressMonitor()); + } catch (CoreException e) { + fail(e.getLocalizedMessage()); + } + } + } + + // Project creation has some async hooks so don't attempt to build it *right* away + Job job = new Job("Validate project") { + @Override + protected IStatus run(IProgressMonitor monitor) { + try { + ensureValidProject(this, project); + return Status.OK_STATUS; + } catch (Exception e) { + fail(e.toString()); + } + return null; + } + }; + job.schedule(1000); + job.join(); + Object property = job.getProperty(ERROR_KEY); + assertNull(property); + } + + private IProject createProject(NewProjectWizardState values) throws InvocationTargetException { + NewProjectWizard wizard = new NewProjectWizard(); + wizard.setValues(values); + wizard.performFinish(new NullProgressMonitor()); + + if (TemplateHandler.sMostRecentException != null) { + fail(values.projectName + ": " + TemplateHandler.sMostRecentException.toString()); + } + + IProject project = wizard.getProject(); + assertNotNull(project); + assertTrue(project.exists()); + System.out.println("Created project " + project + " : " + AdtUtils.getAbsolutePath(project)); + return project; + } + + private void ensureValidProject(@NonNull Job job, @NonNull IProject project) throws Exception { + System.out.println("Begin build error check"); + ensureNoBuildErrors(job, project); + System.out.println("Finished build error check"); + + System.out.println("Begin lint check"); + ensureNoLintWarnings(job, project); + System.out.println("Finished lint check"); + + sCount++; + } + + private void ensureNoLintWarnings(final Job job, IProject project) { + System.setProperty("com.android.tools.lint.bindir", AdtPrefs.getPrefs().getOsSdkFolder() + + File.separator + FD_TOOLS); + + LintDriver driver = new LintDriver(EclipseLintClient.getRegistry(), new LintClient() { + @Override + public void report(@NonNull Context context, + @NonNull Issue issue, @NonNull Severity severity, + @Nullable Location location, @NonNull String message, @NonNull TextFormat format) { + String s = "Found lint error: " + issue.getId() + ": " + message + " at " + location; + job.setProperty(ERROR_KEY, s); + fail(s); + } + + @Override + public Configuration getConfiguration(@NonNull Project p) { + return new DefaultConfiguration(this, p, null, new File("dummy.xml")) { + @Override + public boolean isEnabled(@NonNull Issue issue) { + // Doesn't work: hangs in unit test context, something about + // loading native libs. + if (issue.getCategory() == Category.ICONS){ + return false; + } + + if (issue == ManifestDetector.TARGET_NEWER) { + // Don't complain about targetSdk < latest: we're deliberately + // testing that (to make sure templates compile etc in compat + // mode) + return false; + } + + if (issue == SecurityDetector.EXPORTED_SERVICE + || issue == SecurityDetector.EXPORTED_PROVIDER + || issue == SecurityDetector.EXPORTED_RECEIVER) { + // Don't complain about missing permissions when exporting: the + // unit test is deliberately turning on exported + return false; + } + + return true; + } + }; + } + + @Override + @NonNull + public String readFile(@NonNull File file) { + try { + return Files.toString(file, Charsets.UTF_8); + } catch (IOException e) { + fail(e.toString() + " for " + file.getPath()); + return ""; + } + } + + @Override + public void log(@NonNull Severity severity, @Nullable Throwable exception, + @Nullable String format, @Nullable Object... args) { + if (exception != null) { + exception.printStackTrace(); + } + if (format != null) { + if (args != null) { + System.err.println("Log: " + String.format(format, args)); + } else { + System.err.println("Unexpected log message " + format); + } + } + } + + @Override + @Nullable + public JavaParser getJavaParser(@Nullable Project project) { + return new EclipseLintClient(null, null, null, false).getJavaParser(project); + } + + @Override + public XmlParser getXmlParser() { + return new EclipseLintClient(null, null, null, false).getXmlParser(); + } + }); + File projectDir = AdtUtils.getAbsolutePath(project).toFile(); + assertNotNull(projectDir); + assertTrue(projectDir.getPath(), projectDir.isDirectory()); + driver.analyze(Collections.singletonList(projectDir), Scope.ALL); + } + + // Wait for test build support. + // This is copied from {@link SampleProjectTest} + + private void ensureNoBuildErrors(final Job job, final IProject project) throws Exception { + File projectDir = AdtUtils.getAbsolutePath(project).toFile(); + + // Checking the build in Eclipse doesn't work well, because of asynchronous issues + // (it looks like not all necessary changes are applied, and even adding waits works + // unpredictably.) + // + // So instead we do it via the command line. + // First add ant support: + // $ android update project -p . + // Then we run ant and look at the exit code to make sure it worked. + + List<String> command = new ArrayList<String>(); + command.add(AdtPlugin.getOsSdkToolsFolder() + "android" + + (CURRENT_PLATFORM == PLATFORM_WINDOWS ? ".bat" : "")); + command.add("update"); + command.add("project"); + command.add("-p"); + command.add(projectDir.getPath()); + + // launch the command line process + Process process = Runtime.getRuntime().exec(command.toArray(new String[command.size()])); + + + OutputGrabber processOutput = new OutputGrabber(); + int status = GrabProcessOutput.grabProcessOutput( + process, + Wait.WAIT_FOR_READERS, // we really want to make sure we get all the output! + processOutput); + if (status != 0) { + fail(processOutput.getOutput().toString() + processOutput.getError().toString()); + } + assertEquals(0, status); + + // Run ant + String antCmd = "ant" + (CURRENT_PLATFORM == PLATFORM_WINDOWS ? ".bat" : ""); + String antTarget = "debug"; + process = Runtime.getRuntime().exec(antCmd + " " + antTarget, null, projectDir); + processOutput = new OutputGrabber(); + status = GrabProcessOutput.grabProcessOutput( + process, + Wait.WAIT_FOR_READERS, // we really want to make sure we get all the output! + processOutput); + if (status != 0) { + fail(processOutput.getOutput().toString() + processOutput.getError().toString()); + } + assertEquals(0, status); + System.out.println("Ant succeeded (code=" + status + ")"); + } +} |