diff options
author | Tor Norbye <tnorbye@google.com> | 2012-11-28 15:09:44 -0800 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2012-11-28 15:09:44 -0800 |
commit | 32bc57a2c2cab3a5363cd162a54e0ecc3a914618 (patch) | |
tree | fb274bd7e8f61b5399d01aa33817e3157eef9159 | |
parent | 54fa1460e4d547b80dd8fc3d84b51219341fcfaa (diff) | |
parent | b293ca775054871164e9e3c83833a2fd4601387c (diff) | |
download | sdk-32bc57a2c2cab3a5363cd162a54e0ecc3a914618.zip sdk-32bc57a2c2cab3a5363cd162a54e0ecc3a914618.tar.gz sdk-32bc57a2c2cab3a5363cd162a54e0ecc3a914618.tar.bz2 |
Merge "Add sdktestutils package and consolidate some test utility code"
119 files changed, 2584 insertions, 1824 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/GridLayoutConverter.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/GridLayoutConverter.java index 868d790..fe673a5 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/GridLayoutConverter.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/GridLayoutConverter.java @@ -15,8 +15,7 @@ */ package com.android.ide.eclipse.adt.internal.editors.layout.refactoring; -import static com.android.ide.common.layout.GravityHelper.GRAVITY_HORIZ_MASK; -import static com.android.ide.common.layout.GravityHelper.GRAVITY_VERT_MASK; +import static com.android.SdkConstants.ANDROID_URI; import static com.android.SdkConstants.ATTR_BACKGROUND; import static com.android.SdkConstants.ATTR_COLUMN_COUNT; import static com.android.SdkConstants.ATTR_LAYOUT_ALIGN_BASELINE; @@ -34,10 +33,10 @@ import static com.android.SdkConstants.ATTR_LAYOUT_ROW_SPAN; import static com.android.SdkConstants.ATTR_LAYOUT_WIDTH; import static com.android.SdkConstants.ATTR_ORIENTATION; import static com.android.SdkConstants.FQCN_GRID_LAYOUT; +import static com.android.SdkConstants.FQCN_SPACE; import static com.android.SdkConstants.GRAVITY_VALUE_FILL; import static com.android.SdkConstants.GRAVITY_VALUE_FILL_HORIZONTAL; import static com.android.SdkConstants.GRAVITY_VALUE_FILL_VERTICAL; -import static com.android.SdkConstants.GRID_LAYOUT; import static com.android.SdkConstants.ID_PREFIX; import static com.android.SdkConstants.LINEAR_LAYOUT; import static com.android.SdkConstants.NEW_ID_PREFIX; @@ -51,10 +50,9 @@ import static com.android.SdkConstants.VALUE_HORIZONTAL; import static com.android.SdkConstants.VALUE_MATCH_PARENT; import static com.android.SdkConstants.VALUE_VERTICAL; import static com.android.SdkConstants.VALUE_WRAP_CONTENT; +import static com.android.ide.common.layout.GravityHelper.GRAVITY_HORIZ_MASK; +import static com.android.ide.common.layout.GravityHelper.GRAVITY_VERT_MASK; - -import com.android.SdkConstants; -import static com.android.SdkConstants.ANDROID_URI; import com.android.ide.common.api.IViewMetadata.FillPreference; import com.android.ide.common.layout.BaseLayoutRule; import com.android.ide.common.layout.GravityHelper; @@ -66,7 +64,9 @@ import com.android.ide.eclipse.adt.internal.editors.layout.descriptors.ViewEleme 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.gre.ViewMetadataRepository; +import com.android.ide.eclipse.adt.internal.project.SupportLibraryHelper; +import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.IStatus; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.text.edits.InsertEdit; @@ -227,9 +227,12 @@ class GridLayoutConverter { int column = columnFixed.size(); StringBuilder sb = new StringBuilder(64); String spaceTag = SPACE; - if (!gridLayout.equals(GRID_LAYOUT) && gridLayout.length() > GRID_LAYOUT.length()) { - String pkg = gridLayout.substring(0, gridLayout.length() - GRID_LAYOUT.length()); - spaceTag = pkg + spaceTag; + IFile file = mRefactoring.getFile(); + if (file != null) { + spaceTag = SupportLibraryHelper.getTagFor(file.getProject(), FQCN_SPACE); + if (spaceTag.equals(FQCN_SPACE)) { + spaceTag = SPACE; + } } sb.append('<').append(spaceTag).append(' '); diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/UseCompoundDrawableRefactoring.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/UseCompoundDrawableRefactoring.java index 99a6c81..b96d31a 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/UseCompoundDrawableRefactoring.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/UseCompoundDrawableRefactoring.java @@ -353,8 +353,10 @@ public class UseCompoundDrawableRefactoring extends VisualRefactoring { } } - String xml = XmlPrettyPrinter.prettyPrint(tempDocument, XmlFormatPreferences.create(), + String xml = XmlPrettyPrinter.prettyPrint(tempDocument.getDocumentElement(), + XmlFormatPreferences.create(), XmlFormatStyle.LAYOUT, null); + TextEdit replace = new ReplaceEdit(mSelectionStart, mSelectionEnd - mSelectionStart, xml); rootEdit.addChild(replace); diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/VisualRefactoring.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/VisualRefactoring.java index 15744e8..5939a8a 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/VisualRefactoring.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/VisualRefactoring.java @@ -294,6 +294,10 @@ public abstract class VisualRefactoring extends Refactoring { return args; } + IFile getFile() { + return mFile; + } + // ---- Shared functionality ---- diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/refactorings/changes/AndroidDocumentChange.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/refactorings/changes/AndroidDocumentChange.java index c0a9283..eb8ccc7 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/refactorings/changes/AndroidDocumentChange.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/refactorings/changes/AndroidDocumentChange.java @@ -78,6 +78,15 @@ public class AndroidDocumentChange extends DocumentChange { super(SdkConstants.FN_ANDROID_MANIFEST_XML, document); } + /** + * Returns the manifest file + * + * @return the manifest + */ + public IFile getManifest() { + return mAndroidManifest; + } + @Override public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException, OperationCanceledException { diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/refactorings/changes/AndroidLayoutChange.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/refactorings/changes/AndroidLayoutChange.java index 85c038d..7bac6d7 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/refactorings/changes/AndroidLayoutChange.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/refactorings/changes/AndroidLayoutChange.java @@ -91,6 +91,10 @@ public class AndroidLayoutChange extends DocumentChange { } } + public IFile getFile() { + return mFile; + } + @Override public String getName() { return mFile.getName(); diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/.classpath b/eclipse/plugins/com.android.ide.eclipse.tests/.classpath index 1f464fb..ae0cb35 100644 --- a/eclipse/plugins/com.android.ide.eclipse.tests/.classpath +++ b/eclipse/plugins/com.android.ide.eclipse.tests/.classpath @@ -6,6 +6,7 @@ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="lib" path="kxml2-2.3.0.jar"/> <classpathentry kind="lib" path="easymock.jar"/> + <classpathentry kind="lib" path="sdktestutils.jar"/> <classpathentry combineaccessrules="false" kind="src" path="/ddmlib"/> <classpathentry combineaccessrules="false" kind="src" path="/ddmuilib"/> <classpathentry kind="lib" path="/plugin-adt/libs/ninepatch.jar" sourcepath="/ninepatch"/> diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/META-INF/MANIFEST.MF b/eclipse/plugins/com.android.ide.eclipse.tests/META-INF/MANIFEST.MF index c853ecb..a432c10 100644 --- a/eclipse/plugins/com.android.ide.eclipse.tests/META-INF/MANIFEST.MF +++ b/eclipse/plugins/com.android.ide.eclipse.tests/META-INF/MANIFEST.MF @@ -9,6 +9,7 @@ Require-Bundle: org.junit Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Bundle-ClassPath: kxml2-2.3.0.jar, ., + sdktestutils.jar, layoutlib.jar, lint_api.jar, lint_checks.jar, diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/build.properties b/eclipse/plugins/com.android.ide.eclipse.tests/build.properties index a79421c..436573e 100644 --- a/eclipse/plugins/com.android.ide.eclipse.tests/build.properties +++ b/eclipse/plugins/com.android.ide.eclipse.tests/build.properties @@ -7,6 +7,7 @@ bin.includes = META-INF/,\ prefs.template,\ unittest.xml,\ kxml2-2.3.0.jar,\ + sdktestutils.jar,\ layoutlib.jar,\ lint_api.jar, lint_checks.jar, 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 index 68995ae..7fb9cdb 100644 --- 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 @@ -19,8 +19,8 @@ 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.SdkConstants; 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; @@ -32,7 +32,7 @@ import com.android.ide.eclipse.adt.internal.preferences.AdtPrefs; 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.SdkTestCase; +import com.android.ide.eclipse.tests.SdkLoadingTestCase; import com.android.sdklib.IAndroidTarget; import org.eclipse.core.resources.IContainer; @@ -51,31 +51,19 @@ 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.BufferedReader; import java.io.ByteArrayInputStream; import java.io.File; import java.io.InputStream; -import java.io.InputStreamReader; import java.lang.reflect.InvocationTargetException; -import java.util.Calendar; import java.util.HashMap; import java.util.Map; @SuppressWarnings({"restriction", "javadoc"}) -public class AdtProjectTest extends SdkTestCase { +public abstract class AdtProjectTest extends SdkLoadingTestCase { private static final int TARGET_API_LEVEL = 12; public static final String TEST_PROJECT_PACKAGE = "com.android.eclipse.tests"; //$NON-NLS-1$ - - /** Update golden files if different from the actual results */ - private static final boolean UPDATE_DIFFERENT_FILES = false; - /** Create golden files if missing */ - private static final boolean UPDATE_MISSING_FILES = true; - private static final String TEST_DATA_REL_PATH = - "eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/" - + "internal/editors/layout/refactoring/testdata"; - private static final String PROJECTNAME_PREFIX = "testproject-"; private static final long TESTS_START_TIME = System.currentTimeMillis(); - private static File sTempDir = null; + 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 @@ -85,6 +73,23 @@ public class AdtProjectTest extends SdkTestCase { 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(); @@ -147,7 +152,10 @@ public class AdtProjectTest extends SdkTestCase { assertNotNull(project); sProjectMap.put(projectName, project); } - + if (!testCaseNeedsUniqueProject() && !testNeedsUniqueProject()) { + addCleanupDir(AdtUtils.getAbsolutePath(project).toFile()); + } + addCleanupDir(project.getFullPath().toFile()); return project; } @@ -243,12 +251,19 @@ public class AdtProjectTest extends SdkTestCase { 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; @@ -270,8 +285,7 @@ public class AdtProjectTest extends SdkTestCase { } private static IProject getProject(String name) { - IProject iproject = ResourcesPlugin.getWorkspace().getRoot() - .getProject(name); + IProject iproject = ResourcesPlugin.getWorkspace().getRoot().getProject(name); return iproject; } @@ -282,33 +296,6 @@ public class AdtProjectTest extends SdkTestCase { return getCaretOffset(fileContent, caretLocation); } - protected int getCaretOffset(String fileContent, String caretLocation) { - assertTrue(caretLocation, caretLocation.contains("^")); //$NON-NLS-1$ - - int caretDelta = caretLocation.indexOf("^"); //$NON-NLS-1$ - assertTrue(caretLocation, caretDelta != -1); - - // 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); - 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 = fileContent.indexOf(caretContext); - assertTrue("Caret content " + caretContext + " not found in file", - caretContextIndex != -1); - return caretContextIndex + caretDelta; - } - /** * If the given caret location string contains a selection range, select that range in * the given viewer @@ -361,107 +348,9 @@ public class AdtProjectTest extends SdkTestCase { return addSelection(newFileContents, selectionBegin, selectionEnd); } - protected String addSelection(String newFileContents, int selectionBegin, int selectionEnd) { - // Insert selection markers -- [ ] for the selection range, ^ for the caret - String newFileWithCaret; - if (selectionBegin < selectionEnd) { - newFileWithCaret = newFileContents.substring(0, selectionBegin) + "[^" - + newFileContents.substring(selectionBegin, selectionEnd) + "]" - + newFileContents.substring(selectionEnd); - } else { - // Selected range - newFileWithCaret = newFileContents.substring(0, selectionBegin) + "^" - + newFileContents.substring(selectionBegin); - } - - return newFileWithCaret; - } - - protected String getCaretContext(String file, int offset) { - int windowSize = 20; - int begin = Math.max(0, offset - windowSize / 2); - int end = Math.min(file.length(), offset + windowSize / 2); - - return "..." + file.substring(begin, offset) + "^" + file.substring(offset, end) + "..."; - } - - /** - * Very primitive line differ, intended for files where there are very minor changes - * (such as code completion apply-tests) - */ - protected String getDiff(String before, String after) { - // Do line by line analysis - String[] beforeLines = before.split("\n"); - String[] afterLines = after.split("\n"); - - int firstDelta = 0; - for (; firstDelta < Math.min(beforeLines.length, afterLines.length); firstDelta++) { - if (!beforeLines[firstDelta].equals(afterLines[firstDelta])) { - break; - } - } - - if (firstDelta == beforeLines.length && firstDelta == afterLines.length) { - return ""; - } - - // Counts from the end of both arrays - int lastDelta = 0; - for (; lastDelta < Math.min(beforeLines.length, afterLines.length); lastDelta++) { - if (!beforeLines[beforeLines.length - 1 - lastDelta].equals( - afterLines[afterLines.length - 1 - lastDelta])) { - break; - } - } - - boolean showBeforeWindow = firstDelta >= beforeLines.length - lastDelta; - boolean showAfterWindow = firstDelta >= afterLines.length - lastDelta; - - StringBuilder sb = new StringBuilder(); - if (showAfterWindow && firstDelta > 0) { - sb.append(" "); - sb.append(afterLines[firstDelta - 1]); - sb.append('\n'); - } - for (int i = firstDelta; i < beforeLines.length - lastDelta; i++) { - sb.append("<"); - if (beforeLines[i].length() > 0) { - sb.append(" "); - } - sb.append(beforeLines[i]); - sb.append('\n'); - } - if (showAfterWindow && lastDelta < afterLines.length - 1) { - sb.append(" "); - sb.append(afterLines[afterLines.length - (lastDelta -1)]); - sb.append('\n'); - } - - sb.append("---\n"); - - if (showBeforeWindow && firstDelta > 0) { - sb.append(" "); - sb.append(beforeLines[firstDelta - 1]); - sb.append('\n'); - } - for (int i = firstDelta; i < afterLines.length - lastDelta; i++) { - sb.append(">"); - if (afterLines[i].length() > 0) { - sb.append(" "); - } - sb.append(afterLines[i]); - sb.append('\n'); - } - if (showBeforeWindow && lastDelta < beforeLines.length - 1) { - sb.append(" "); - sb.append(beforeLines[beforeLines.length - (lastDelta -1)]); - sb.append('\n'); - } - - return sb.toString(); - } - + @Override protected String removeSessionData(String data) { + data = super.removeSessionData(data); if (getProject() != null) { data = data.replace(getProject().getName(), "PROJECTNAME"); } @@ -493,122 +382,6 @@ public class AdtProjectTest extends SdkTestCase { return createNode(null, fqn, hasChildren); } - protected String readTestFile(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; - } - - assertNotNull(relativePath + " does not exist", stream); - - BufferedReader reader = new BufferedReader(new InputStreamReader(stream)); - String xml = AdtPlugin.readFile(reader); - assertNotNull(xml); - assertTrue(xml.length() > 0); - - // Remove any references to the project name such that we are isolated from - // that in golden file. - // Appears in strings.xml etc. - xml = removeSessionData(xml); - - return xml; - } - - protected void assertEqualsGolden(String basename, String actual) { - assertEqualsGolden(basename, actual, basename.substring(basename.lastIndexOf('.') + 1)); - } - - protected void assertEqualsGolden(String basename, String actual, String newExtension) { - String testName = getName(); - if (testName.startsWith("test")) { - testName = testName.substring(4); - if (Character.isUpperCase(testName.charAt(0))) { - testName = Character.toLowerCase(testName.charAt(0)) + testName.substring(1); - } - } - String expectedName; - String extension = basename.substring(basename.lastIndexOf('.') + 1); - if (newExtension == null) { - newExtension = extension; - } - expectedName = basename.substring(0, basename.indexOf('.')) - + "-expected-" + testName + '.' + newExtension; - String expected = readTestFile(expectedName, false); - if (expected == null) { - File expectedPath = new File( - UPDATE_MISSING_FILES ? getTargetDir() : getTempDir(), expectedName); - AdtPlugin.writeFile(expectedPath, actual); - System.out.println("Expected - written to " + expectedPath + ":\n"); - System.out.println(actual); - fail("Did not find golden file (" + expectedName + "): Wrote contents as " - + expectedPath); - } else { - if (!expected.replaceAll("\r\n", "\n").equals(actual.replaceAll("\r\n", "\n"))) { - File expectedPath = new File(getTempDir(), expectedName); - File actualPath = new File(getTempDir(), - expectedName.replace("expected", "actual")); - AdtPlugin.writeFile(expectedPath, expected); - AdtPlugin.writeFile(actualPath, actual); - // Also update data dir with the current value - if (UPDATE_DIFFERENT_FILES) { - AdtPlugin.writeFile( new File(getTargetDir(), expectedName), actual); - } - System.out.println("The files differ: diff " + expectedPath + " " - + actualPath); - assertEquals("The files differ - see " + expectedPath + " versus " + actualPath, - expected, actual); - } - } - } - - /** Get the location to write missing golden files to */ - protected File getTargetDir() { - // Set $ADT_SDK_SOURCE_PATH to point to your git "sdk" directory; if done, then - // if you run a unit test which refers to a golden file which does not exist, it - // will be created directly into the test data directory and you can rerun the - // test - // and it should pass (after you verify that the golden file contains the correct - // result of course). - String sdk = System.getenv("ADT_SDK_SOURCE_PATH"); - if (sdk != null) { - File sdkPath = new File(sdk); - if (sdkPath.exists()) { - File testData = new File(sdkPath, TEST_DATA_REL_PATH.replace('/', - File.separatorChar)); - if (testData.exists()) { - return testData; - } - } - } - return getTempDir(); - } - - protected File getTempDir() { - if (SdkConstants.CURRENT_PLATFORM == SdkConstants.PLATFORM_DARWIN) { - return new File("/tmp"); //$NON-NLS-1$ - } - - if (sTempDir == null) { - // On Windows, we don't want to pollute the temp folder (which is generally - // already incredibly busy). So let's create a temp folder for the results. - - File base = new File(System.getProperty("java.io.tmpdir")); //$NON-NLS-1$ - - Calendar c = Calendar.getInstance(); - String name = String.format("adtTests_%1$tF_%1$tT", c).replace(':', '-'); //$NON-NLS-1$ - File tmpDir = new File(base, name); - if (!tmpDir.exists() && tmpDir.mkdir()) { - sTempDir = tmpDir; - } else { - sTempDir = base; - } - } - - return sTempDir; - } - /** Special editor context set on the model to be rendered */ protected static class TestLayoutEditorDelegate extends LayoutEditorDelegate { 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 index 4c55323..a716a75 100644 --- 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 @@ -107,6 +107,11 @@ public class ChangeLayoutRefactoringTest extends RefactoringTest { 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); 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 index 86fc8a7..9565183 100644 --- 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 @@ -116,6 +116,9 @@ public class RefactoringTest extends AdtProjectTest { 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); @@ -138,12 +141,13 @@ public class RefactoringTest extends AdtProjectTest { } protected void checkEdits(List<Change> changes, - Map<IPath, String> fileToGoldenName) throws BadLocationException { + 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 { + Map<IPath, String> fileToGoldenName, boolean createDiffs) + throws BadLocationException, IOException { for (Change change : changes) { if (change instanceof TextFileChange) { TextFileChange tf = (TextFileChange) change; @@ -214,7 +218,7 @@ public class RefactoringTest extends AdtProjectTest { * <p> * Each file can be generated by the dump method in the ViewHierarchy. */ - protected ViewInfo createInfos(UiElementNode model, String relativePath) { + 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); 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 index e946327..01a0e1e 100644 --- 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 @@ -17,9 +17,12 @@ 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; @@ -90,7 +93,8 @@ public class UseCompoundDrawableRefactoringTest extends RefactoringTest { checkRefactoring("refactoring/usecompound/compound7.xml", "@+id/layout1"); } - private void checkRefactoring(String basename, String id) throws Exception { + private void checkRefactoring(String basename, String id) + throws Exception { IFile file = getLayoutFile(getProject(), basename); TestContext info = setupTestContext(file, basename); TestLayoutEditorDelegate layoutEditor = info.mLayoutEditorDelegate; @@ -99,6 +103,12 @@ public class UseCompoundDrawableRefactoringTest extends RefactoringTest { 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/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 index 51a2cc9..4ce3540 100644 --- 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 @@ -1,4 +1,4 @@ Code completion in broken1.xml for android:textColorHigh^ selecting android:textColorHighlight: -< android:textColorHigh^ ---- -> 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/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 index 21437b9..3337ad2 100644 --- 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 @@ -1,4 +1,4 @@ Code completion in broken2.xml for style=^ selecting "@android:": -< style=^ ---- -> style="@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/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 index 3e60eb9..2787380 100644 --- 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 @@ -1,4 +1,4 @@ Code completion in broken3.xml for <EditT^ selecting EditText />: -< <EditT^ ---- -> <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/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 index d656509..6b05566 100644 --- 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 @@ -1,4 +1,4 @@ Code completion in completion1.xml for layout_w^idth="fill_parent" selecting android:layout_weight: -< android:layout_w^idth="fill_parent" ---- -> android:layout_weight^="fill_parent" +@@ -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 index 824fa25..7b448c2 100644 --- 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 @@ -1,4 +1,4 @@ Code completion in completion1.xml for <T^extView selecting TableLayout: -< <T^extView ---- -> <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 index 7f4ec86..1a5f24d 100644 --- 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 @@ -1,4 +1,4 @@ Code completion in completion1.xml for ^<TextView selecting <RadioGroup ></RadioGroup>: -< ^<TextView ---- -> <RadioGroup ^></RadioGroup><TextView +@@ -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 index 384c4a9..9010bf6 100644 --- 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 @@ -1,4 +1,4 @@ Code completion in completion1.xml for ^<TextView selecting <CheckBox />: -< ^<TextView ---- -> <CheckBox ^/><TextView +@@ -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 index a4b7231..a7a4638 100644 --- 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 @@ -1,4 +1,4 @@ Code completion in completion1.xml for btn_default">^</FrameLayout> selecting <FrameLayout ></FrameLayout>: -< <FrameLayout android:foreground="@android:drawable/btn_default">^</FrameLayout> ---- -> <FrameLayout android:foreground="@android:drawable/btn_default"><FrameLayout ^></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 index a410606..7776131 100644 --- 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 @@ -1,4 +1,4 @@ Code completion in completion1.xml for layout_width="^fill_parent" selecting match_parent: -< android:layout_width="^fill_parent" ---- -> android:layout_width="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 index 578f8ea..e67a336 100644 --- 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 @@ -1,4 +1,4 @@ Code completion in completion1.xml for layout_width="fi^ll_parent" selecting fill_parent: -< android:layout_width="fi^ll_parent" ---- -> android:layout_width="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 index 577089b..fe63acd 100644 --- 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 @@ -1,4 +1,4 @@ Code completion in completion1.xml for marginBottom="50"^ selecting android:maxEms: -< android:layout_marginBottom="50"^ ---- -> android:layout_marginBottom="50" 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 index ebbba89..2d229f3 100644 --- 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 @@ -1,4 +1,4 @@ Code completion in completion1.xml for marginBottom="50^" selecting 50mm: -< android:layout_marginBottom="50^" ---- -> android:layout_marginBottom="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 index ba7cb0b..5a2b413 100644 --- 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 @@ -1,4 +1,4 @@ Code completion in completion1.xml for layout_marginLeft="50d^p" selecting 50dp: -< android:layout_marginLeft="50d^p" ---- -> android:layout_marginLeft="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 index f1e6465..d3a8c11 100644 --- 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 @@ -1,4 +1,4 @@ Code completion in completion1.xml for style="@android:^style/Widget.Button" selecting @android:drawable/: -< style="@android:^style/Widget.Button" ---- -> style="@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 index 1a577db..afd7e21 100644 --- 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 @@ -1,4 +1,4 @@ Code completion in completion1.xml for android:gravity="l^eft|bottom" selecting left: -< android:gravity="l^eft|bottom" ---- -> android:gravity="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 index 2560011..73f2bd4 100644 --- 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 @@ -1,4 +1,4 @@ Code completion in completion1.xml for android:gravity="left|b^ottom" selecting bottom: -< android:gravity="left|b^ottom" ---- -> android:gravity="left|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-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 index 05656fb..1b4198e 100644 --- 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 @@ -1,4 +1,4 @@ Code completion in completion1.xml for layout_width=^"fill_parent" selecting "wrap_content": -< android:layout_width=^"fill_parent" ---- -> android:layout_width="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/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 index dcd7f71..af28a13 100644 --- 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 @@ -1,4 +1,4 @@ Code completion in completion10.xml for "[^wrap_content]" selecting fill_parent: -< android:layout_height="^wrap_content"/> ---- -> android:layout_height="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 index a8d2d43..0a4d338 100644 --- 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 @@ -1,4 +1,4 @@ Code completion in completion10.xml for "[^wrap_c]ontent" selecting fill_parent: -< android:layout_height="^wrap_content"/> ---- -> android:layout_height="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/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 index 981a931..321deaa 100644 --- 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 @@ -1,4 +1,4 @@ Code completion in completion11.xml for ?android:attr/Textapp^ selecting ?android:attr/textAppearanceLargeInverse: -< style="?android:attr/Textapp^" ---- -> style="?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/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 index 13e224e..b365736 100644 --- 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 @@ -1,4 +1,4 @@ Code completion in completion2.xml for gravity="left|bottom|^cen selecting fill_vertical: -< <TextView android:gravity="left|bottom|^cen"></TextView> ---- -> <TextView android:gravity="left|bottom|fill_vertical^"></TextView> +@@ -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 index 5d1b39e..46268af 100644 --- 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 @@ -1,4 +1,4 @@ Code completion in completion2.xml for gravity="left|bottom|cen^ selecting center_horizontal: -< <TextView android:gravity="left|bottom|cen^"></TextView> ---- -> <TextView android:gravity="left|bottom|center_horizontal^"></TextView> +@@ -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 index 0c7e564..bcac56d 100644 --- 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 @@ -1,4 +1,4 @@ Code completion in completion2.xml for gravity="left|bottom^|cen selecting bottom|fill_horizontal: -< <TextView android:gravity="left|bottom^|cen"></TextView> ---- -> <TextView android:gravity="left|bottom|fill_horizontal^"></TextView> +@@ -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/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 index 14bb9ac..ef070b2 100644 --- 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 @@ -1,4 +1,4 @@ Code completion in completion3.xml for <EditText ^/> selecting android:textColorHighlight: -< <EditText ^/> ---- -> <EditText 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 index a751a3e..283636b 100644 --- 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 @@ -1,4 +1,4 @@ Code completion in completion3.xml for <Button ^></Button> selecting android:paddingRight: -< <Button ^></Button> ---- -> <Button android:paddingRight="^"></Button> +@@ -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/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 index 16f42b2..3f78663 100644 --- 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 @@ -1,4 +1,4 @@ Code completion in completion5.xml for android:orientation='^' selecting horizontal: -< android:orientation='^' ---- -> android:orientation='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 index dd48af1..4933d13 100644 --- 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 @@ -1,4 +1,4 @@ Code completion in completion5.xml for android:layout_marginTop='50^dp' selecting 50pt: -< android:layout_marginTop='50^dp' ---- -> android:layout_marginTop='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 index 40e5bb1..a4c88d7 100644 --- 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 @@ -1,4 +1,4 @@ Code completion in completion5.xml for android:layout_width='^wrap_content' selecting match_parent: -< android:layout_width='^wrap_content' ---- -> android:layout_width='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 index 00ffd0a..705f865 100644 --- 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 @@ -1,4 +1,4 @@ Code completion in completion5.xml for android:id='@+id/button2'^ selecting android:maxWidth: -< android:id='@+id/button2'^ ---- -> android:id='@+id/button2' 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/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 index 8ea8837..92cd2f2 100644 --- 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 @@ -1,4 +1,4 @@ Code completion in completion6.xml for android:orientation="^" selecting horizontal: -< android:orientation="^" ---- -> android:orientation="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-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 index d874fc1..1aaadc2 100644 --- 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 @@ -1,4 +1,4 @@ Code completion in completion7.xml for android:orientation="^ selecting horizontal: -< android:orientation="^ ---- -> android:orientation="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/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 index 9a1b962..7678740 100644 --- 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 @@ -1,4 +1,4 @@ Code completion in completion8.xml for android:mar^="50dp" selecting android:layout_marginRight: -< android:mar^="50dp" ---- -> android:layout_marginRight^="50dp" +@@ -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/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 index 4b88448..d323219 100644 --- 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 @@ -1,4 +1,4 @@ Code completion in completionvalues1.xml for android:textS^ize selecting android:textSelectHandleLeft: -< <item name="android:textS^ize">17sp</item> ---- -> <item name="android:textSelectHandleLeft"^>17sp</item> +@@ -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 index acfd3ab..ac71df7 100644 --- 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 @@ -1,4 +1,4 @@ Code completion in completionvalues1.xml for 17^sp selecting 17mm: -< <item name="android:textSize">17^sp</item> ---- -> <item name="android:textSize">17mm^</item> +@@ -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 index ba7a1f2..df6fceb 100644 --- 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 @@ -1,4 +1,4 @@ Code completion in completionvalues1.xml for textColor">^@color/title_color</item> selecting @android:: -< <item name="android:textColor">^@color/title_color</item> ---- -> <item name="android:textColor">@android:^</item> +@@ -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 index 491363b..36fce8b 100644 --- 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 @@ -1,4 +1,4 @@ Code completion in completionvalues1.xml for <item name="android:shadowColor">@an^</item> selecting @android:: -< <item name="android:shadowColor">@an^</item> ---- -> <item name="android:shadowColor">@android:^</item> +@@ -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 index 1c999c7..6315fc4 100644 --- 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 @@ -1,4 +1,4 @@ Code completion in completionvalues1.xml for <item name="android:gravity">^ </item> selecting center_vertical: -< <item name="android:gravity">^ </item> ---- -> <item name="android:gravity">center_vertical^</item> +@@ -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 index fbfa7a8..1db9773 100644 --- 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 @@ -1,4 +1,4 @@ Code completion in completionvalues1.xml for <item name="android:gravity"> ^</item> selecting left: -< <item name="android:gravity"> ^</item> ---- -> <item name="android:gravity"> left^</item> +@@ -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 index 3e2cf0d..6307646 100644 --- 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 @@ -1,4 +1,4 @@ Code completion in completionvalues1.xml for <item name="gr^"> selecting android:gravity: -< <item name="gr^">@color/title_color</item> ---- -> <item name="android:gravity"^>@color/title_color</item> +@@ -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 index 5f79eaf..c8a119f 100644 --- 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 @@ -1,4 +1,4 @@ Code completion in completionvalues1.xml for <item name="an^"> selecting android:animateOnClick: -< <item name="an^">@color/title_color</item> ---- -> <item name="android:animateOnClick"^>@color/title_color</item> +@@ -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 index 8f83183..9b37438 100644 --- 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 @@ -1,4 +1,4 @@ Code completion in completionvalues1.xml for <item ^></item> selecting name: -< <item ^></item> ---- -> <item name="^"></item> +@@ -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 index 1a68f13..b34a8ec 100644 --- 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 @@ -1,4 +1,4 @@ Code completion in completionvalues1.xml for <item name="^"></item> selecting android:background: -< <item name="^"></item> ---- -> <item name="android:background"^></item> +@@ -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 index 1a61da3..b78adee 100644 --- 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 @@ -1,4 +1,4 @@ Code completion in completionvalues1.xml for <item name="android:allowSingleTap">^</item> selecting true: -< <item name="android:allowSingleTap">^</item> ---- -> <item name="android:allowSingleTap">true^</item> +@@ -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 index da4d30f..5af6c92 100644 --- 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 @@ -1,4 +1,4 @@ Code completion in completionvalues1.xml for <item name="android:alwaysDrawnWithCache">^ false </item> selecting true: -< <item name="android:alwaysDrawnWithCache">^ false </item> ---- -> <item name="android:alwaysDrawnWithCache">true^</item> +@@ -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 index 4334c9f..f48f101 100644 --- 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 @@ -1,4 +1,4 @@ Code completion in completionvalues1.xml for <item name="android:alwaysDrawnWithCache"> ^false </item> selecting true: -< <item name="android:alwaysDrawnWithCache"> ^false </item> ---- -> <item name="android:alwaysDrawnWithCache"> true^</item> +@@ -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 index 2c9f547..8c246a8 100644 --- 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 @@ -1,4 +1,4 @@ Code completion in completionvalues1.xml for <item name="android:alwaysDrawnWithCache"> f^alse </item> selecting false: -< <item name="android:alwaysDrawnWithCache"> f^alse </item> ---- -> <item name="android:alwaysDrawnWithCache"> false^</item> +@@ -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 index 195e159..082f2b2 100644 --- 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 @@ -1,4 +1,4 @@ Code completion in completionvalues1.xml for <item name="android:orientation">h^</item> selecting horizontal: -< <item name="android:orientation">h^</item> ---- -> <item name="android:orientation">horizontal^</item> +@@ -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 index 0e81810..47580e1 100644 --- 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 @@ -1,4 +1,4 @@ Code completion in completionvalues1.xml for c^ selecting center: -< c^ ---- -> 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 index 7a845b3..57fe472 100644 --- 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 @@ -1,4 +1,4 @@ Code completion in completionvalues1.xml for [^false] selecting true: -< <item name="android:alwaysDrawnWithCache"> ^false </item> ---- -> <item name="android:alwaysDrawnWithCache"> true^</item> +@@ -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/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 index 95d078c..e21c594 100644 --- 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 @@ -1,34 +1,34 @@ -< 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> -> +@@ -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 index 3c3d47f..8c12b7c 100644 --- 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 @@ -1,31 +1,31 @@ -< 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> -> +@@ -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 index 33ff9db..c819b09 100644 --- 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 @@ -1,32 +1,32 @@ -< 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> -> +@@ -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 index 33ff9db..c819b09 100644 --- 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 @@ -1,32 +1,32 @@ -< 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> -> +@@ -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 index e4d3412..36186b8 100644 --- 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 @@ -1,32 +1,32 @@ -< 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> -> +@@ -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 index 9094011..83837f5 100644 --- 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 @@ -1,33 +1,33 @@ -< 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> -> +@@ -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 index c7cdba6..55d658d 100644 --- 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 @@ -1,33 +1,33 @@ -< 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> -> +@@ -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-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 index 3c3d47f..8c12b7c 100644 --- 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 @@ -1,31 +1,31 @@ -< 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> -> +@@ -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/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 index a4dd387..bb2960e 100644 --- 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 @@ -1,33 +1,33 @@ -< 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> -> +@@ -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/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 index 141180b..8890f79 100644 --- 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 @@ -1,6 +1,5 @@ ---- - </style> -> <style name="newstyle"> -> <item name="android:textColor">#FF00FF</item> -> <item name="android:textSize">20pt</item> - </resources> +@@ -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/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 index 1958ae5..6772a8f 100644 --- 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 @@ -1,11 +1,12 @@ -< ---- -> <?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> +@@ -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 index 871a14d..d0fdc92 100644 --- 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 @@ -1,30 +1,29 @@ -< ---- -> <?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" > -> -> <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> +@@ -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 index 7f076e7..0949fbd 100644 --- 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 @@ -1,9 +1,10 @@ -< ---- -> <?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> +@@ -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 index 7f076e7..0949fbd 100644 --- 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 @@ -1,9 +1,10 @@ -< ---- -> <?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> +@@ -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 index 7f076e7..0949fbd 100644 --- 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 @@ -1,9 +1,10 @@ -< ---- -> <?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> +@@ -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 index 01d0697..e8b553e 100644 --- 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 @@ -1,9 +1,10 @@ -< ---- -> <?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> +@@ -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 index 7f076e7..0949fbd 100644 --- 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 @@ -1,9 +1,10 @@ -< ---- -> <?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> +@@ -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 index 8f2e543..88a94e7 100644 --- 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 @@ -1,9 +1,10 @@ -< ---- -> <?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> +@@ -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 index 3013eb5..49043b9 100644 --- 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 @@ -1,8 +1,9 @@ -< ---- -> <?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> +@@ -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 index 7980fae..49ab2c3 100644 --- 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 @@ -1,8 +1,9 @@ -< ---- -> <?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> +@@ -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/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 index 9e4ee25..6bcd6ff 100644 --- 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 @@ -1,9 +1,10 @@ -< ---- -> <?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> +@@ -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 index 2ef716b..a51abf4 100644 --- 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 @@ -1,6 +1,7 @@ <?xml version="1.0" encoding="utf-8"?> <resources> - <string name="hello">Hello World!</string> + <string name="app_name">PROJECTNAME</string> <string name="firststring">[^TODO]</string> -</resources> + +</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-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 index 8773027..900c420 100644 --- 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 @@ -1,8 +1,8 @@ <?xml version="1.0" encoding="utf-8"?> -<LinearLayout - xmlns:android="http://schemas.android.com/apk/res/android" - android:orientation="vertical" - android:layout_width="match_parent" - android:layout_height="match_parent"> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical" > ^ -</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/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 index 025fa0a..7b638c6 100644 --- 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 @@ -1,3 +1,4 @@ -< <color android:color="#0000000"/> ---- -> <color android:color="#0000000" xmlns:android="http://schemas.android.com/apk/res/android"/> +@@ -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/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 index faa95d7..98e1f36 100644 --- 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 @@ -3,6 +3,7 @@ android:id="@+id/LinearLayout1" android:layout_width="match_parent" android:layout_height="match_parent" + android:columnCount="2" android:orientation="horizontal" > <Button @@ -15,6 +16,8 @@ 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 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 index 8f19186..aa8ecda 100644 --- 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 @@ -3,6 +3,7 @@ android:id="@+id/LinearLayout1" android:layout_width="match_parent" android:layout_height="match_parent" + android:columnCount="2" android:orientation="vertical" > <Button @@ -15,6 +16,8 @@ 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 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 index c0ebd59..1ae5748 100644 --- 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 @@ -1,9 +1,9 @@ -< <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"/> +@@ -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 index 0a0b809..6d18aab 100644 --- 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 @@ -1,86 +1,84 @@ -< <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 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> -> </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> -> </LinearLayout> -> -> <include -> android:id="@+id/linearLayout4_ref" -> android:layout_width="match_parent" -> android:layout_height="wrap_content" -> layout="@layout/newlayout6" /> -> +@@ -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/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 index 5a55498..366c8df 100644 --- 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 @@ -3,10 +3,10 @@ <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:layout_toRightOf="@+id/button2"></ImageButton> + <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:id="@+id/ImageButton2" android:layout_alignParentRight="true"></ImageButton> + <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/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 index 636e301..8a01599 100644 --- 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 @@ -1,10 +1,10 @@ -< <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"/> +@@ -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 index 96e6dfb..3de135d 100644 --- 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 @@ -1,70 +1,69 @@ -< <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 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> -> </LinearLayout> -> -> <Button -> android:id="@+id/button4" -> android:layout_width="match_parent" -> android:layout_height="wrap_content" -> android:text="FourthButton" > -> </Button> -> +@@ -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/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 index 024141a..ea3afc2 100644 --- 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 @@ -1,15 +1,15 @@ -< <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"/> +@@ -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 index 1774968..8228b59 100644 --- 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 @@ -1,95 +1,85 @@ -< <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 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" /> -> </FrameLayout> -> -> <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 -> android:id="@+id/linearLayout6" -> android:layout_width="wrap_content" -> android:layout_height="match_parent" > -> -> <Button -> android:id="@+id/button6" -> android:layout_width="wrap_content" -> android:layout_height="wrap_content" -> android:text="Button" > -> </Button> -> </LinearLayout> -> </LinearLayout> -> </LinearLayout> -> </FrameLayout> -> +@@ -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/lint/ProjectLintConfigurationTest.java b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/lint/ProjectLintConfigurationTest.java index 9f0783f..088ece7 100644 --- 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 @@ -33,7 +33,6 @@ import com.android.tools.lint.detector.api.Severity; import org.eclipse.core.resources.IProject; import java.io.File; -import java.util.Calendar; @SuppressWarnings("javadoc") public class ProjectLintConfigurationTest extends AdtProjectTest { @@ -181,31 +180,11 @@ public class ProjectLintConfigurationTest extends AdtProjectTest { assertSame(config1, config2); } - private static File sTempDir = null; - @Override - protected File getTempDir() { - if (sTempDir == null) { - File base = new File(System.getProperty("java.io.tmpdir")); //$NON-NLS-1$ - String os = System.getProperty("os.name"); //$NON-NLS-1$ - if (os.startsWith("Mac OS")) { //$NON-NLS-1$ - base = new File("/tmp"); - } - Calendar c = Calendar.getInstance(); - String name = String.format("lintTests/%1$tF_%1$tT", c).replace(':', '-'); //$NON-NLS-1$ - File tmpDir = new File(base, name); - if (!tmpDir.exists() && tmpDir.mkdirs()) { - sTempDir = tmpDir; - } else { - sTempDir = base; - } - } - - return sTempDir; - } - @Override protected File getTargetDir() { - return new File(getTempDir(), getClass().getSimpleName() + "_" + getName()); + File targetDir = new File(getTempDir(), getClass().getSimpleName() + "_" + getName()); + addCleanupDir(targetDir); + return targetDir; } private static class TestClient extends LintClient { 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 0000000..3ae8535 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/refactorings/core/RefactoringTestBase.java @@ -0,0 +1,476 @@ +/* + * 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.ide.eclipse.adt.AdtUtils; +import com.android.ide.eclipse.adt.internal.editors.layout.refactoring.AdtProjectTest; +import com.android.ide.eclipse.adt.internal.refactorings.changes.AndroidLayoutChange; +import com.android.ide.eclipse.adt.internal.refactorings.changes.AndroidPackageRenameChange; +import com.android.ide.eclipse.adt.internal.refactorings.changes.AndroidTypeRenameChange; +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.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.RenameResourceChange; +import org.eclipse.text.edits.TextEdit; + +import java.io.File; +import java.io.IOException; + +@SuppressWarnings({"javadoc","restriction"}) +public abstract class RefactoringTestBase extends AdtProjectTest { + protected void checkRefactoring(Refactoring refactoring, String expected) + throws Exception { + RefactoringStatus status = refactoring.checkAllConditions(new NullProgressMonitor()); + assertNotNull(status); + if (!status.isOK()) { + assertEquals(status.toString(), expected); + 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); + } + } + + protected IProject createProject(Object[] testData) throws Exception { + String name = getName(); + IProject project = createProject(name); + 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); + sb.append("* "); + sb.append(changeName); + if (change instanceof TextFileChange) { + TextFileChange tfc = (TextFileChange) change; + sb.append(" - "); + sb.append(tfc.getFile().getFullPath()); + sb.append('\n'); + } else { + sb.append('\n'); + } + if (change instanceof TextFileChange + || change instanceof AndroidLayoutChange + || change instanceof AndroidTypeRenameChange + || change instanceof AndroidPackageRenameChange) { + TextChange tc = (TextChange) change; + TextEdit edit = tc.getEdit(); + IFile file = null; + if (change instanceof TextFileChange) { + TextFileChange tfc = (TextFileChange) change; + file = tfc.getFile(); + } else if (change instanceof AndroidPackageRenameChange) { + AndroidPackageRenameChange aprc = (AndroidPackageRenameChange) change; + file = aprc.getManifest(); + } else if (change instanceof AndroidTypeRenameChange) { + AndroidTypeRenameChange aprc = (AndroidTypeRenameChange) change; + file = aprc.getManifest(); + } else { + assert change instanceof AndroidLayoutChange; + AndroidLayoutChange alc = (AndroidLayoutChange) change; + file = alc.getFile(); + } + byte[] bytes = ByteStreams.toByteArray(file.getContents()); + String before = new String(bytes, Charsets.UTF_8); + IDocument document = new Document(); + document.replace(0, 0, before); + edit.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 RenameResourceChange) { + // Change name, appended above, is adequate + } else if (change instanceof RenamePackageChange) { + // Change name, appended above, is adequate + } else if (change instanceof AndroidPackageRenameChange) { + AndroidPackageRenameChange aprc = (AndroidPackageRenameChange) change; + aprc.getEdit(); + } else if (change instanceof AndroidLayoutChange) { + AndroidLayoutChange tfc = (AndroidLayoutChange) change; + TextEdit edit = tfc.getEdit(); + tfc.getModifiedElement(); + IFile file = tfc.getFile(); + byte[] bytes = ByteStreams.toByteArray(file.getContents()); + String before = new String(bytes, Charsets.UTF_8); + IDocument document = new Document(); + document.replace(0, 0, before); + edit.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 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(); + for (Change child : children) { + describe(sb, child, indent + (composite.isSynthetic() ? 0 : 1)); + } + } + } + + 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" + + " </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_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" + + "</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" + + "\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, + + "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, + }; +} 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 index a5d2a9a..90b49fb 100644 --- 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 @@ -16,43 +16,25 @@ package com.android.ide.eclipse.adt.internal.refactorings.core; import com.android.annotations.NonNull; -import com.android.ide.eclipse.adt.AdtUtils; import com.android.ide.eclipse.adt.internal.editors.Hyperlinks; -import com.android.ide.eclipse.adt.internal.editors.layout.refactoring.AdtProjectTest; import com.android.ide.eclipse.adt.internal.project.BaseProjectHelper; import com.android.resources.ResourceType; import com.android.utils.Pair; -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.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.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.RefactoringStatus; -import org.eclipse.ltk.core.refactoring.TextFileChange; import org.eclipse.ltk.core.refactoring.participants.RenameProcessor; import org.eclipse.ltk.core.refactoring.participants.RenameRefactoring; -import org.eclipse.ltk.core.refactoring.resource.RenameResourceChange; -import org.eclipse.text.edits.TextEdit; - -import java.io.File; -import java.io.IOException; @SuppressWarnings({"javadoc", "restriction"}) -public class RenameResourceParticipantTest extends AdtProjectTest { +public class RenameResourceParticipantTest extends RefactoringTestBase { public void testRefactor1() throws Exception { - checkRefactoring( + renameResource( TEST_PROJECT, "@string/app_name", true /*updateReferences*/, @@ -61,33 +43,28 @@ public class RenameResourceParticipantTest extends AdtProjectTest { "CHANGES:\n" + "-------\n" + "* AndroidManifest.xml - /testRefactor1/AndroidManifest.xml\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" + - " ---\n" + - " > android:label=\"@string/myname\"\n" + - " > android:theme=\"@style/AppTheme\" >\n" + - " > <activity\n" + - " > android:name=\"com.example.refactoringtest.MainActivity\"\n" + - " > android:label=\"@string/myname\" >\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\" >\n" + "\n" + "\n" + "* strings.xml - /testRefactor1/res/values/strings.xml\n" + - " < <string name=\"app_name\">RefactoringTest</string>\n" + - " ---\n" + - " > <string name=\"myname\">RefactoringTest</string>\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" + - " < public static final int app_name=0x7f040000;\n" + - " ---\n" + - " > public static final int myname=0x7f040000;"); + " @@ -29 +29\n" + + " - public static final int app_name=0x7f040000;\n" + + " + public static final int myname=0x7f040000;"); } public void testRefactor2() throws Exception { - checkRefactoring( + renameResource( TEST_PROJECT, "@+id/menu_settings", true /*updateReferences*/, @@ -96,19 +73,19 @@ public class RenameResourceParticipantTest extends AdtProjectTest { "CHANGES:\n" + "-------\n" + "* activity_main.xml - /testRefactor2/res/menu/activity_main.xml\n" + - " < android:id=\"@+id/menu_settings\"\n" + - " ---\n" + - " > android:id=\"@+id/new_id_for_the_action_bar\"\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" + - " < public static final int menu_settings=0x7f070003;\n" + - " ---\n" + - " > public static final int new_id_for_the_action_bar=0x7f070003;"); + " @@ -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 { - checkRefactoring( + renameResource( TEST_PROJECT, "@+id/textView1", true /*updateReferences*/, @@ -117,49 +94,30 @@ public class RenameResourceParticipantTest extends AdtProjectTest { "CHANGES:\n" + "-------\n" + "* activity_main.xml - /testRefactor3/res/layout/activity_main.xml\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" + - " ---\n" + - " > android:id=\"@+id/output\"\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/output\"\n" + - " > android:layout_below=\"@+id/output\"\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" + "* MainActivity.java - /testRefactor3/src/com/example/refactoringtest/MainActivity.java\n" + - " < View view1 = findViewById(R.id.textView1);\n" + - " ---\n" + - " > View view1 = findViewById(R.id.output);\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" + - " < public static final int textView1=0x7f070000;\n" + - " ---\n" + - " > public static final int output=0x7f070000;"); + " @@ -20 +20\n" + + " - public static final int textView1=0x7f070000;\n" + + " + public static final int output=0x7f070000;"); } public void testRefactor4() throws Exception { - checkRefactoring( + renameResource( TEST_PROJECT, // same as testRefactor3, but use @id rather than @+id even though @+id is in file "@id/textView1", @@ -169,49 +127,30 @@ public class RenameResourceParticipantTest extends AdtProjectTest { "CHANGES:\n" + "-------\n" + "* activity_main.xml - /testRefactor4/res/layout/activity_main.xml\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" + - " ---\n" + - " > android:id=\"@+id/output\"\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/output\"\n" + - " > android:layout_below=\"@+id/output\"\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" + "* MainActivity.java - /testRefactor4/src/com/example/refactoringtest/MainActivity.java\n" + - " < View view1 = findViewById(R.id.textView1);\n" + - " ---\n" + - " > View view1 = findViewById(R.id.output);\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" + - " < public static final int textView1=0x7f070000;\n" + - " ---\n" + - " > public static final int output=0x7f070000;"); + " @@ -20 +20\n" + + " - public static final int textView1=0x7f070000;\n" + + " + public static final int output=0x7f070000;"); } public void testRefactor5() throws Exception { - checkRefactoring( + renameResource( TEST_PROJECT, "@layout/activity_main", true /*updateReferences*/, @@ -220,21 +159,23 @@ public class RenameResourceParticipantTest extends AdtProjectTest { "CHANGES:\n" + "-------\n" + "* Rename 'testRefactor5/res/layout/activity_main.xml' to 'newlayout.xml'\n" + + "\n" + "* Rename 'testRefactor5/res/layout-land/activity_main.xml' to 'newlayout.xml'\n" + + "\n" + "* MainActivity.java - /testRefactor5/src/com/example/refactoringtest/MainActivity.java\n" + - " < setContentView(R.layout.activity_main);\n" + - " ---\n" + - " > setContentView(R.layout.newlayout);\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" + - " < public static final int activity_main=0x7f030000;\n" + - " ---\n" + - " > public static final int newlayout=0x7f030000;"); + " @@ -23 +23\n" + + " - public static final int activity_main=0x7f030000;\n" + + " + public static final int newlayout=0x7f030000;"); } public void testRefactor6() throws Exception { - checkRefactoring( + renameResource( TEST_PROJECT, "@drawable/ic_launcher", true /*updateReferences*/, @@ -243,26 +184,30 @@ public class RenameResourceParticipantTest extends AdtProjectTest { "CHANGES:\n" + "-------\n" + "* AndroidManifest.xml - /testRefactor6/AndroidManifest.xml\n" + - " < android:icon=\"@drawable/ic_launcher\"\n" + - " ---\n" + - " > android:icon=\"@drawable/newlauncher\"\n" + + " @@ -12 +12\n" + + " - android:icon=\"@drawable/ic_launcher\"\n" + + " + android:icon=\"@drawable/newlauncher\"\n" + "\n" + "\n" + "* Rename 'testRefactor6/res/drawable-hdpi/ic_launcher.png' to 'newlauncher.png'\n" + + "\n" + "* Rename 'testRefactor6/res/drawable-ldpi/ic_launcher.png' to 'newlauncher.png'\n" + + "\n" + "* Rename 'testRefactor6/res/drawable-mdpi/ic_launcher.png' to 'newlauncher.png'\n" + + "\n" + "* Rename 'testRefactor6/res/drawable-xhdpi/ic_launcher.png' to 'newlauncher.png'\n" + + "\n" + "* R.java - /testRefactor6/gen/com/example/refactoringtest/R.java\n" + - " < public static final int ic_launcher=0x7f020000;\n" + - " ---\n" + - " > public static final int newlauncher=0x7f020000;"); + " @@ -14 +14\n" + + " - public static final int ic_launcher=0x7f020000;\n" + + " + public static final int newlauncher=0x7f020000;"); } 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"); - checkRefactoring( + renameResource( project, file, true /*updateReferences*/, @@ -271,17 +216,19 @@ public class RenameResourceParticipantTest extends AdtProjectTest { "CHANGES:\n" + "-------\n" + "* Rename 'testRefactor7/res/layout/activity_main.xml' to 'newlayout.xml'\n" + + "\n" + "* Rename 'testRefactor7/res/layout-land/activity_main.xml' to 'newlayout.xml'\n" + + "\n" + "* MainActivity.java - /testRefactor7/src/com/example/refactoringtest/MainActivity.java\n" + - " < setContentView(R.layout.activity_main);\n" + - " ---\n" + - " > setContentView(R.layout.newlayout);\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" + - " < public static final int activity_main=0x7f030000;\n" + - " ---\n" + - " > public static final int newlayout=0x7f030000;"); + " @@ -23 +23\n" + + " - public static final int activity_main=0x7f030000;\n" + + " + public static final int newlayout=0x7f030000;"); } public void testRefactor8() throws Exception { @@ -300,7 +247,7 @@ public class RenameResourceParticipantTest extends AdtProjectTest { assertNotNull(field); assertTrue(field.exists()); - checkRefactoring( + renameResource( project, field, true /*updateReferences*/, @@ -309,23 +256,24 @@ public class RenameResourceParticipantTest extends AdtProjectTest { "CHANGES:\n" + "-------\n" + "* MainActivity.java - /testRefactor8/src/com/example/refactoringtest/MainActivity.java\n" + - " < setContentView(R.layout.activity_main);\n" + - " ---\n" + - " > setContentView(R.layout.newlauncher);\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" + - " < public static final int activity_main=0x7f030000;\n" + - " ---\n" + - " > public static final int newlauncher=0x7f030000;\n" + + " @@ -23 +23\n" + + " - public static final int activity_main=0x7f030000;\n" + + " + public static final int newlauncher=0x7f030000;\n" + "\n" + "\n" + "* Rename 'testRefactor8/res/layout/activity_main.xml' to 'newlauncher.xml'\n" + + "\n" + "* Rename 'testRefactor8/res/layout-land/activity_main.xml' to 'newlauncher.xml'"); } public void testInvalidName() throws Exception { - checkRefactoring( + renameResource( TEST_PROJECT, "@drawable/ic_launcher", true /*updateReferences*/, @@ -342,7 +290,7 @@ public class RenameResourceParticipantTest extends AdtProjectTest { public void testRefactor9() throws Exception { // same as testRefactor4, but not updating references - checkRefactoring( + renameResource( TEST_PROJECT, "@id/textView1", false /*updateReferences*/, @@ -351,30 +299,30 @@ public class RenameResourceParticipantTest extends AdtProjectTest { "CHANGES:\n" + "-------\n" + "* activity_main.xml - /testRefactor9/res/layout/activity_main.xml\n" + - " < android:id=\"@+id/textView1\"\n" + - " ---\n" + - " > android:id=\"@+id/output\"\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" + - " < public static final int textView1=0x7f070000;\n" + - " ---\n" + - " > public static final int output=0x7f070000;"); + " @@ -20 +20\n" + + " - public static final int textView1=0x7f070000;\n" + + " + public static final int output=0x7f070000;"); } - // ---- Only test infrastructure below ---- + // ---- Test infrastructure ---- - private void checkRefactoring( + protected void renameResource( @NonNull Object[] testData, @NonNull Object resource, boolean updateReferences, @NonNull String newName, @NonNull String expected) throws Exception { IProject project = createProject(testData); - checkRefactoring(project, resource, updateReferences, newName, expected); + renameResource(project, resource, updateReferences, newName, expected); } - private void checkRefactoring( + protected void renameResource( @NonNull IProject project, @NonNull Object resource, boolean updateReferences, @@ -414,376 +362,6 @@ public class RenameResourceParticipantTest extends AdtProjectTest { assertNotNull(processor); RenameRefactoring refactoring = new RenameRefactoring(processor); - RefactoringStatus status = refactoring.checkAllConditions(new NullProgressMonitor()); - assertNotNull(status); - if (!status.isOK()) { - assertEquals(status.toString(), expected); - 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 createProject(Object[] testData) throws Exception { - String name = getName(); - IProject project = createProject(name); - 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; - } - - private 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(); - } - - private 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 { - // Describe this change - indent(sb, indent); - sb.append("* "); - sb.append(change.getName()); - if (change instanceof TextFileChange) { - TextFileChange tfc = (TextFileChange) change; - sb.append(" - "); - sb.append(tfc.getFile().getFullPath()); - sb.append('\n'); - } - if (change instanceof TextFileChange) { - TextFileChange tfc = (TextFileChange) change; - TextEdit edit = tfc.getEdit(); - IFile file = tfc.getFile(); - byte[] bytes = ByteStreams.toByteArray(file.getContents()); - String before = new String(bytes, Charsets.UTF_8); - IDocument document = new Document(); - document.replace(0, 0, before); - edit.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 RenameResourceChange) { - // Change name, appended above, is adequate - } 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(); - for (Change child : children) { - describe(sb, child, indent + (composite.isSynthetic() ? 0 : 1)); - } - } + checkRefactoring(refactoring, expected); } - - private static void indent(StringBuilder sb, int indent) { - for (int i = 0; i < indent; i++) { - sb.append(" "); - } - } - - private 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 - - private 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" + - " </application>\n" + - "\n" + - "</manifest>"; - - private 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"; - - private 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" + - "</RelativeLayout>"; - - private 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" + - "\n" + - "</RelativeLayout>"; - - - private 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>"; - - private 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>"; - - private 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>"; - - private 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"; - - private static final Object[] TEST_PROJECT = new Object[] { - "AndroidManifest.xml", - SAMPLE_MANIFEST, - - "src/com/example/refactoringtest/MainActivity.java", - SAMPLE_MAIN_ACTIVITY, - - "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, - }; }
\ 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 index 7fac5b0..80df145 100644 --- 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 @@ -30,7 +30,7 @@ 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.SdkTestCase; +import com.android.ide.eclipse.tests.SdkLoadingTestCase; import com.android.sdklib.IAndroidTarget; import com.android.sdklib.util.GrabProcessOutput; import com.android.sdklib.util.GrabProcessOutput.IProcessOutput; @@ -91,7 +91,7 @@ import java.util.Set; * TODO: Test adding multiple instances of the templates (to look for resource conflicts) */ @SuppressWarnings("javadoc") -public class TemplateHandlerTest extends SdkTestCase { +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 diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/tests/SdkTestCase.java b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/tests/SdkLoadingTestCase.java index 84c238e..65ce8e1 100644 --- a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/tests/SdkTestCase.java +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/tests/SdkLoadingTestCase.java @@ -21,20 +21,19 @@ import com.android.ide.eclipse.adt.internal.preferences.AdtPrefs; import com.android.ide.eclipse.adt.internal.sdk.AndroidTargetParser; import com.android.ide.eclipse.adt.internal.sdk.Sdk; import com.android.sdklib.IAndroidTarget; +import com.android.testutils.SdkTestCase; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.NullProgressMonitor; -import junit.framework.TestCase; - /** * A test case which uses the SDK loaded by the ADT plugin. */ -public abstract class SdkTestCase extends TestCase { +public abstract class SdkLoadingTestCase extends SdkTestCase { private Sdk mSdk; - protected SdkTestCase() { + protected SdkLoadingTestCase() { } /** @@ -107,10 +106,12 @@ public abstract class SdkTestCase extends TestCase { if (!validateSdk(target)) { continue; } + if (false) { // This takes forEVER IStatus status = new AndroidTargetParser(target).run(new NullProgressMonitor()); if (status.getCode() != IStatus.OK) { fail("Failed to parse targets data"); } + } } } } diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/tests/functests/layoutRendering/ApiDemosRenderingTest.java b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/tests/functests/layoutRendering/ApiDemosRenderingTest.java index 2b364a5..8b46f87 100644 --- a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/tests/functests/layoutRendering/ApiDemosRenderingTest.java +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/tests/functests/layoutRendering/ApiDemosRenderingTest.java @@ -47,7 +47,7 @@ import com.android.ide.common.resources.configuration.TouchScreenQualifier; import com.android.ide.common.sdk.LoadStatus; import com.android.ide.eclipse.adt.internal.resources.manager.ResourceManager; import com.android.ide.eclipse.adt.internal.sdk.AndroidTargetData; -import com.android.ide.eclipse.tests.SdkTestCase; +import com.android.ide.eclipse.tests.SdkLoadingTestCase; import com.android.io.FolderWrapper; import com.android.resources.Density; import com.android.resources.Keyboard; @@ -74,7 +74,7 @@ import java.util.Map; import javax.imageio.ImageIO; -public class ApiDemosRenderingTest extends SdkTestCase { +public class ApiDemosRenderingTest extends SdkLoadingTestCase { /** * Custom parser that implements {@link ILayoutPullParser} (which itself extends diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/tests/functests/sampleProjects/SampleProjectTest.java b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/tests/functests/sampleProjects/SampleProjectTest.java index 656e8e8..3fb705d 100644 --- a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/tests/functests/sampleProjects/SampleProjectTest.java +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/tests/functests/sampleProjects/SampleProjectTest.java @@ -20,7 +20,7 @@ import com.android.ide.eclipse.adt.AdtUtils; 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.SdkTestCase; +import com.android.ide.eclipse.tests.SdkLoadingTestCase; import com.android.sdklib.IAndroidTarget; import org.eclipse.core.resources.IMarker; @@ -50,7 +50,7 @@ import java.util.logging.Logger; * execution there * */ -public class SampleProjectTest extends SdkTestCase { +public class SampleProjectTest extends SdkLoadingTestCase { private static final Logger sLogger = Logger.getLogger(SampleProjectTest.class.getName()); diff --git a/eclipse/scripts/create_all_symlinks.sh b/eclipse/scripts/create_all_symlinks.sh index 4e32353..3130cf1 100755 --- a/eclipse/scripts/create_all_symlinks.sh +++ b/eclipse/scripts/create_all_symlinks.sh @@ -156,7 +156,7 @@ CP_FILES="$CP_FILES @:$DDMS_DEST $DDMS_LIBS $DDMS_PREBUILTS" ### TEST ### TEST_DEST="sdk/eclipse/plugins/com.android.ide.eclipse.tests" -TEST_LIBS="easymock" +TEST_LIBS="easymock sdktestutils" TEST_PREBUILTS="prebuilts/misc/common/kxml2/kxml2-2.3.0.jar" LIBS="$LIBS $TEST_LIBS" diff --git a/lint/libs/lint_checks/tests/.classpath b/lint/libs/lint_checks/tests/.classpath index 2c94b75..24bb642 100644 --- a/lint/libs/lint_checks/tests/.classpath +++ b/lint/libs/lint_checks/tests/.classpath @@ -13,6 +13,7 @@ <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/lombok-ast/lombok-ast-0.2.jar" sourcepath="/ANDROID_SRC/prebuilts/tools/common/lombok-ast/src.zip"/> <classpathentry combineaccessrules="false" kind="src" path="/layoutlib_api"/> <classpathentry combineaccessrules="false" kind="src" path="/common"/> + <classpathentry combineaccessrules="false" kind="src" path="/testutils"/> <classpathentry combineaccessrules="false" kind="src" path="/SdkLib"/> <classpathentry kind="output" path="bin"/> </classpath> diff --git a/lint/libs/lint_checks/tests/Android.mk b/lint/libs/lint_checks/tests/Android.mk index 9f591f6..cfbf734 100644 --- a/lint/libs/lint_checks/tests/Android.mk +++ b/lint/libs/lint_checks/tests/Android.mk @@ -22,7 +22,7 @@ LOCAL_SRC_FILES := $(call all-java-files-under, src) LOCAL_MODULE := lint_checks-tests LOCAL_MODULE_TAGS := optional -LOCAL_JAVA_LIBRARIES := common sdklib lint_api lint_checks lint junit easymock asm-tools asm-tree-tools guava-tools layoutlib_api +LOCAL_JAVA_LIBRARIES := common sdklib lint_api lint_checks lint junit easymock asm-tools asm-tree-tools guava-tools layoutlib_api sdktestutils include $(BUILD_HOST_JAVA_LIBRARY) diff --git a/lint/libs/lint_checks/tests/src/com/android/tools/lint/XmlReporterTest.java b/lint/libs/lint_checks/tests/src/com/android/tools/lint/XmlReporterTest.java index 166f721..b4ca0f1 100644 --- a/lint/libs/lint_checks/tests/src/com/android/tools/lint/XmlReporterTest.java +++ b/lint/libs/lint_checks/tests/src/com/android/tools/lint/XmlReporterTest.java @@ -112,7 +112,9 @@ public class XmlReporterTest extends AbstractCheckTest { "\n" + "* When creating configuration variations (for example for landscape or portrait)you have to repeat the actual text (and keep it up to date when making changes)\n" + "\n" + - "* The application cannot be translated to other languages by just adding new translations for existing string resources.\"\n" + + "* The application cannot be translated to other languages by just adding new translations for existing string resources.\n" + + "\n" + + "In Eclipse there is a quickfix to automatically extract this hardcoded string into a resource lookup.\"\n" + " errorLine1=\" (java.lang.String) android:text="Fooo" />\"\n" + " errorLine2=\" ~~~~~~~~~~~~~~~~~~~\">\n" + " <location\n" + @@ -211,7 +213,9 @@ public class XmlReporterTest extends AbstractCheckTest { "\n" + "* When creating configuration variations (for example for landscape or portrait)you have to repeat the actual text (and keep it up to date when making changes)\n" + "\n" + - "* The application cannot be translated to other languages by just adding new translations for existing string resources.\"\n" + + "* The application cannot be translated to other languages by just adding new translations for existing string resources.\n" + + "\n" + + "In Eclipse there is a quickfix to automatically extract this hardcoded string into a resource lookup.\"\n" + " errorLine1=\" (java.lang.String) android:text="Fooo" />\"\n" + " errorLine2=\" ~~~~~~~~~~~~~~~~~~~\">\n" + " <location\n" + diff --git a/lint/libs/lint_checks/tests/src/com/android/tools/lint/checks/AbstractCheckTest.java b/lint/libs/lint_checks/tests/src/com/android/tools/lint/checks/AbstractCheckTest.java index 0978dc1..d54962a 100644 --- a/lint/libs/lint_checks/tests/src/com/android/tools/lint/checks/AbstractCheckTest.java +++ b/lint/libs/lint_checks/tests/src/com/android/tools/lint/checks/AbstractCheckTest.java @@ -18,6 +18,7 @@ package com.android.tools.lint.checks; import com.android.annotations.NonNull; import com.android.annotations.Nullable; +import com.android.testutils.SdkTestCase; import com.android.tools.lint.LintCliXmlParser; import com.android.tools.lint.LombokParser; import com.android.tools.lint.Main; @@ -37,8 +38,6 @@ 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.google.common.io.Files; -import com.google.common.io.InputSupplier; import java.io.File; import java.io.FileWriter; @@ -49,16 +48,13 @@ import java.net.URISyntaxException; import java.net.URL; import java.security.CodeSource; import java.util.ArrayList; -import java.util.Calendar; import java.util.Collections; import java.util.EnumSet; import java.util.List; -import junit.framework.TestCase; - /** Common utility methods for the various lint check tests */ @SuppressWarnings("javadoc") -public abstract class AbstractCheckTest extends TestCase { +public abstract class AbstractCheckTest extends SdkTestCase { @Override protected void setUp() throws Exception { super.setUp(); @@ -113,16 +109,6 @@ public abstract class AbstractCheckTest extends TestCase { return checkLint(files); } - protected void deleteFile(File dir) { - if (dir.isDirectory()) { - for (File f : dir.listFiles()) { - deleteFile(f); - } - } else if (dir.isFile()) { - assertTrue(dir.getPath(), dir.delete()); - } - } - protected String checkLint(List<File> files) throws Exception { mOutput = new StringBuilder(); TestLintClient lintClient = createClient(); @@ -163,6 +149,13 @@ public abstract class AbstractCheckTest extends TestCase { return checkLint(Collections.singletonList(projectDir)); } + @Override + protected File getTargetDir() { + File targetDir = new File(getTempDir(), getClass().getSimpleName() + "_" + getName()); + addCleanupDir(targetDir); + return targetDir; + } + /** Creates a project directory structure from the given files */ protected File getProjectDir(String name, String ...relativePaths) throws Exception { assertFalse("getTargetDir must be overridden to make a unique directory", @@ -172,7 +165,9 @@ public abstract class AbstractCheckTest extends TestCase { if (name != null) { projectDir = new File(projectDir, name); } - assertTrue(projectDir.getPath(), projectDir.mkdirs()); + if (!projectDir.exists()) { + assertTrue(projectDir.getPath(), projectDir.mkdirs()); + } List<File> files = new ArrayList<File>(); for (String relativePath : relativePaths) { @@ -203,91 +198,15 @@ public abstract class AbstractCheckTest extends TestCase { private StringBuilder mOutput = null; - protected static File sTempDir = null; - - protected File getTempDir() { - if (sTempDir == null) { - File base = new File(System.getProperty("java.io.tmpdir")); //$NON-NLS-1$ - String os = System.getProperty("os.name"); //$NON-NLS-1$ - if (os.startsWith("Mac OS")) { //$NON-NLS-1$ - base = new File("/tmp"); - } - Calendar c = Calendar.getInstance(); - String name = String.format("lintTests/%1$tF_%1$tT", c).replace(':', '-'); //$NON-NLS-1$ - File tmpDir = new File(base, name); - if (!tmpDir.exists() && tmpDir.mkdirs()) { - sTempDir = tmpDir; - } else { - sTempDir = base; - } - } - - return sTempDir; - } - - protected File getTargetDir() { - return new File(getTempDir(), getClass().getSimpleName() + "_" + getName()); - } - - private File makeTestFile(String name, String relative, - final InputStream contents) throws IOException { - return makeTestFile(getTargetDir(), name, relative, contents); - } - - private File makeTestFile(File dir, String name, String relative, - final InputStream contents) throws IOException { - if (relative != null) { - dir = new File(dir, relative); - if (!dir.exists()) { - boolean mkdir = dir.mkdirs(); - assertTrue(dir.getPath(), mkdir); - } - } else if (!dir.exists()) { - boolean mkdir = dir.mkdirs(); - assertTrue(dir.getPath(), mkdir); - } - File tempFile = new File(dir, name); - if (tempFile.exists()) { - tempFile.delete(); - } - - Files.copy(new InputSupplier<InputStream>() { - @Override - public InputStream getInput() throws IOException { - return contents; - } - }, tempFile); - - return tempFile; - } - - private File getTestfile(File targetDir, String relativePath) throws IOException { - // Support replacing filenames and paths with a => syntax, e.g. - // dir/file.txt=>dir2/dir3/file2.java - // will read dir/file.txt from the test data and write it into the target - // directory as dir2/dir3/file2.java - - String targetPath = relativePath; - int replaceIndex = relativePath.indexOf("=>"); //$NON-NLS-1$ - if (replaceIndex != -1) { - // foo=>bar - targetPath = relativePath.substring(replaceIndex + "=>".length()); - relativePath = relativePath.substring(0, replaceIndex); - } - + @Override + protected InputStream getTestResource(String relativePath, boolean expectExists) { String path = "data" + File.separator + relativePath; //$NON-NLS-1$ InputStream stream = AbstractCheckTest.class.getResourceAsStream(path); - assertNotNull(relativePath + " does not exist", stream); - int index = targetPath.lastIndexOf('/'); - String relative = null; - String name = targetPath; - if (index != -1) { - name = targetPath.substring(index + 1); - relative = targetPath.substring(0, index); + if (!expectExists && stream == null) { + return null; } - - return makeTestFile(targetDir, name, relative, stream); + return stream; } protected boolean isEnabled(Issue issue) { @@ -303,23 +222,6 @@ public abstract class AbstractCheckTest extends TestCase { return false; } - protected static String cleanup(String result) throws IOException { - if (sTempDir != null && result.contains(sTempDir.getPath())) { - result = result.replace(sTempDir.getCanonicalFile().getPath(), "/TESTROOT"); - result = result.replace(sTempDir.getAbsoluteFile().getPath(), "/TESTROOT"); - result = result.replace(sTempDir.getPath(), "/TESTROOT"); - } - - // The output typically contains a few directory/filenames. - // On Windows we need to change the separators to the unix-style - // forward slash to make the test as OS-agnostic as possible. - if (File.separatorChar != '/') { - result = result.replace(File.separatorChar, '/'); - } - - return result; - } - protected EnumSet<Scope> getLintScope(List<File> file) { return null; } @@ -345,7 +247,6 @@ public abstract class AbstractCheckTest extends TestCase { return super.getSuperClass(project, name); } - public String analyze(List<File> files) throws Exception { mDriver = new LintDriver(new CustomIssueRegistry(), this); configureDriver(mDriver); @@ -368,11 +269,7 @@ public abstract class AbstractCheckTest extends TestCase { result = "No warnings."; } - if (sTempDir != null && result.contains(sTempDir.getPath())) { - result = result.replace(sTempDir.getCanonicalFile().getPath(), "/TESTROOT"); - result = result.replace(sTempDir.getAbsoluteFile().getPath(), "/TESTROOT"); - result = result.replace(sTempDir.getPath(), "/TESTROOT"); - } + result = cleanup(result); return result; } diff --git a/lint/libs/lint_checks/tests/src/com/android/tools/lint/checks/UnusedResourceDetectorTest.java b/lint/libs/lint_checks/tests/src/com/android/tools/lint/checks/UnusedResourceDetectorTest.java index 4bd5a88..9113e79 100644 --- a/lint/libs/lint_checks/tests/src/com/android/tools/lint/checks/UnusedResourceDetectorTest.java +++ b/lint/libs/lint_checks/tests/src/com/android/tools/lint/checks/UnusedResourceDetectorTest.java @@ -160,11 +160,10 @@ public class UnusedResourceDetectorTest extends AbstractCheckTest { // string1 is defined and used in the library project // string2 is defined in the library project and used in the master project // string3 is defined in the library project and not used anywhere - "/TESTROOT/UnusedResourceDetectorTest_testMultiProject/LibraryProject/res/values/strings.xml:7: Warning: The resource R.string.string3 appears to be unused [UnusedResources]\n" + + "/TESTROOT/LibraryProject/res/values/strings.xml:7: Warning: The resource R.string.string3 appears to be unused [UnusedResources]\n" + " <string name=\"string3\">String 3</string>\n" + " ~~~~~~~~~~~~~~\n" + - "0 errors, 1 warnings\n" + - "", + "0 errors, 1 warnings\n", checkLint(Arrays.asList(master, library))); } @@ -222,7 +221,7 @@ public class UnusedResourceDetectorTest extends AbstractCheckTest { assertEquals( // The strings are all referenced in the library project's manifest file // which in this project is merged in - "/TESTROOT/UnusedResourceDetectorTest_testNoMerging/LibraryProject/res/values/strings.xml:7: Warning: The resource R.string.string3 appears to be unused [UnusedResources]\n" + + "/TESTROOT/LibraryProject/res/values/strings.xml:7: Warning: The resource R.string.string3 appears to be unused [UnusedResources]\n" + " <string name=\"string3\">String 3</string>\n" + " ~~~~~~~~~~~~~~\n" + "0 errors, 1 warnings\n", diff --git a/testutils/.classpath b/testutils/.classpath new file mode 100644 index 0000000..45f7edb --- /dev/null +++ b/testutils/.classpath @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="src" path="src"/> + <classpathentry kind="src" path="tests/src"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> + <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/> + <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/guava-tools/guava-13.0.1.jar" sourcepath="/ANDROID_SRC/prebuilts/tools/common/guava-tools/src.zip"/> + <classpathentry combineaccessrules="false" kind="src" path="/common"/> + <classpathentry kind="output" path="bin"/> +</classpath> diff --git a/testutils/.gitignore b/testutils/.gitignore new file mode 100644 index 0000000..c745919 --- /dev/null +++ b/testutils/.gitignore @@ -0,0 +1,2 @@ +bin +build diff --git a/testutils/.project b/testutils/.project new file mode 100644 index 0000000..53319e5 --- /dev/null +++ b/testutils/.project @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>testutils</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> diff --git a/testutils/.settings/org.eclipse.jdt.core.prefs b/testutils/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..9dbff07 --- /dev/null +++ b/testutils/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,98 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore +org.eclipse.jdt.core.compiler.annotation.nonnull=com.android.annotations.NonNull +org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=com.android.annotations.NonNullByDefault +org.eclipse.jdt.core.compiler.annotation.nonnullisdefault=disabled +org.eclipse.jdt.core.compiler.annotation.nullable=com.android.annotations.Nullable +org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning +org.eclipse.jdt.core.compiler.problem.deadCode=warning +org.eclipse.jdt.core.compiler.problem.deprecation=warning +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=warning +org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore +org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled +org.eclipse.jdt.core.compiler.problem.fieldHiding=warning +org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning +org.eclipse.jdt.core.compiler.problem.forbiddenReference=error +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=enabled +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore +org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning +org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning +org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=error +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning +org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore +org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error +org.eclipse.jdt.core.compiler.problem.nullReference=error +org.eclipse.jdt.core.compiler.problem.nullSpecInsufficientInfo=warning +org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error +org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=ignore +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning +org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning +org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning +org.eclipse.jdt.core.compiler.problem.potentialNullSpecViolation=error +org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=warning +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore +org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning +org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=enabled +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning +org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=disabled +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.unclosedCloseable=error +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedImport=warning +org.eclipse.jdt.core.compiler.problem.unusedLabel=warning +org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=warning +org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/testutils/Android.mk b/testutils/Android.mk new file mode 100644 index 0000000..2a1f6dc --- /dev/null +++ b/testutils/Android.mk @@ -0,0 +1,38 @@ +# +# Copyright (C) 2008 The Android Open Source Project +# +# 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. +# +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_SRC_FILES := $(call all-java-files-under,src) + +LOCAL_JAR_MANIFEST := manifest.txt + +# IMPORTANT: if you add a new dependency here, please make sure +# to also check the following files: +# testutils/manifest.txt +LOCAL_JAVA_LIBRARIES := \ + common \ + junit \ + guava-tools + +LOCAL_MODULE := sdktestutils + +LOCAL_MODULE_TAGS := optional + +include $(BUILD_HOST_JAVA_LIBRARY) + +# Build all sub-directories +include $(call all-makefiles-under,$(LOCAL_PATH)) diff --git a/testutils/NOTICE b/testutils/NOTICE new file mode 100644 index 0000000..002f1cb --- /dev/null +++ b/testutils/NOTICE @@ -0,0 +1,189 @@ + + Copyright (c) 2005-2012, The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + + 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. + + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS diff --git a/testutils/manifest.txt b/testutils/manifest.txt new file mode 100644 index 0000000..b0f908d --- /dev/null +++ b/testutils/manifest.txt @@ -0,0 +1 @@ +Class-Path: guava-tools.jar diff --git a/testutils/src/com/android/testutils/SdkTestCase.java b/testutils/src/com/android/testutils/SdkTestCase.java new file mode 100644 index 0000000..6a4d54a --- /dev/null +++ b/testutils/src/com/android/testutils/SdkTestCase.java @@ -0,0 +1,436 @@ +/* + * 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.testutils; + +import com.android.SdkConstants; +import com.google.common.base.Charsets; +import com.google.common.collect.Sets; +import com.google.common.io.ByteStreams; +import com.google.common.io.Closeables; +import com.google.common.io.Files; +import com.google.common.io.InputSupplier; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; +import java.util.Set; + +import junit.framework.TestCase; + +/** + * Common test case for SDK unit tests. Contains a number of general utility methods + * to help writing test cases, such as looking up a temporary directory, comparing golden + * files, computing string diffs, etc. + */ +@SuppressWarnings("javadoc") +public class SdkTestCase extends TestCase { + public static final String TEST_PROJECT_PACKAGE = "com.android.eclipse.tests"; //$NON-NLS-1$ + + /** Update golden files if different from the actual results */ + private static final boolean UPDATE_DIFFERENT_FILES = false; + /** Create golden files if missing */ + private static final boolean UPDATE_MISSING_FILES = true; + private static File sTempDir = null; + protected static Set<File> sCleanDirs = Sets.newHashSet(); + + protected String getTestDataRelPath() { + return "eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/" + + "internal/editors/layout/refactoring/testdata"; + } + + public static int getCaretOffset(String fileContent, String caretLocation) { + assertTrue(caretLocation, caretLocation.contains("^")); //$NON-NLS-1$ + + int caretDelta = caretLocation.indexOf("^"); //$NON-NLS-1$ + assertTrue(caretLocation, caretDelta != -1); + + // 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); + 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 = fileContent.indexOf(caretContext); + assertTrue("Caret content " + caretContext + " not found in file", + caretContextIndex != -1); + return caretContextIndex + caretDelta; + } + + public static String addSelection(String newFileContents, int selectionBegin, int selectionEnd) { + // Insert selection markers -- [ ] for the selection range, ^ for the caret + String newFileWithCaret; + if (selectionBegin < selectionEnd) { + newFileWithCaret = newFileContents.substring(0, selectionBegin) + "[^" + + newFileContents.substring(selectionBegin, selectionEnd) + "]" + + newFileContents.substring(selectionEnd); + } else { + // Selected range + newFileWithCaret = newFileContents.substring(0, selectionBegin) + "^" + + newFileContents.substring(selectionBegin); + } + + return newFileWithCaret; + } + + public static String getCaretContext(String file, int offset) { + int windowSize = 20; + int begin = Math.max(0, offset - windowSize / 2); + int end = Math.min(file.length(), offset + windowSize / 2); + + return "..." + file.substring(begin, offset) + "^" + file.substring(offset, end) + "..."; + } + + /** Get the location to write missing golden files to */ + protected File getTargetDir() { + // Set $ADT_SDK_SOURCE_PATH to point to your git "sdk" directory; if done, then + // if you run a unit test which refers to a golden file which does not exist, it + // will be created directly into the test data directory and you can rerun the + // test + // and it should pass (after you verify that the golden file contains the correct + // result of course). + String sdk = System.getenv("ADT_SDK_SOURCE_PATH"); + if (sdk != null) { + File sdkPath = new File(sdk); + if (sdkPath.exists()) { + File testData = new File(sdkPath, getTestDataRelPath().replace('/', + File.separatorChar)); + if (testData.exists()) { + addCleanupDir(testData); + return testData; + } + } + } + return getTempDir(); + } + + public static File getTempDir() { + if (sTempDir == null) { + File base = new File(System.getProperty("java.io.tmpdir")); //$NON-NLS-1$ + if (SdkConstants.CURRENT_PLATFORM == SdkConstants.PLATFORM_DARWIN) { + base = new File("/tmp"); //$NON-NLS-1$ + } + + // On Windows, we don't want to pollute the temp folder (which is generally + // already incredibly busy). So let's create a temp folder for the results. + + Calendar c = Calendar.getInstance(); + String name = String.format("sdkTests_%1$tF_%1$tT", c).replace(':', '-'); //$NON-NLS-1$ + File tmpDir = new File(base, name); + if (!tmpDir.exists() && tmpDir.mkdir()) { + sTempDir = tmpDir; + } else { + sTempDir = base; + } + addCleanupDir(sTempDir); + } + + return sTempDir; + } + + protected String removeSessionData(String data) { + return data; + } + + protected InputStream getTestResource(String relativePath, boolean expectExists) { + String path = "testdata" + File.separator + relativePath; //$NON-NLS-1$ + InputStream stream = SdkTestCase.class.getResourceAsStream(path); + if (!expectExists && stream == null) { + return null; + } + return stream; + } + + @SuppressWarnings("resource") + protected String readTestFile(String relativePath, boolean expectExists) throws IOException { + InputStream stream = getTestResource(relativePath, expectExists); + if (expectExists) { + assertNotNull(relativePath + " does not exist", stream); + } else if (stream == null) { + return null; + } + + String xml = new String(ByteStreams.toByteArray(stream), Charsets.UTF_8); + Closeables.closeQuietly(stream); + assertTrue(xml.length() > 0); + + // Remove any references to the project name such that we are isolated from + // that in golden file. + // Appears in strings.xml etc. + xml = removeSessionData(xml); + + return xml; + } + + protected void assertEqualsGolden(String basename, String actual) throws IOException { + assertEqualsGolden(basename, actual, basename.substring(basename.lastIndexOf('.') + 1)); + } + + protected void assertEqualsGolden(String basename, String actual, String newExtension) + throws IOException { + String testName = getName(); + if (testName.startsWith("test")) { + testName = testName.substring(4); + if (Character.isUpperCase(testName.charAt(0))) { + testName = Character.toLowerCase(testName.charAt(0)) + testName.substring(1); + } + } + String expectedName; + String extension = basename.substring(basename.lastIndexOf('.') + 1); + if (newExtension == null) { + newExtension = extension; + } + expectedName = basename.substring(0, basename.indexOf('.')) + + "-expected-" + testName + '.' + newExtension; + String expected = readTestFile(expectedName, false); + if (expected == null) { + File expectedPath = new File( + UPDATE_MISSING_FILES ? getTargetDir() : getTempDir(), expectedName); + Files.write(actual, expectedPath, Charsets.UTF_8); + System.out.println("Expected - written to " + expectedPath + ":\n"); + System.out.println(actual); + fail("Did not find golden file (" + expectedName + "): Wrote contents as " + + expectedPath); + } else { + if (!expected.replaceAll("\r\n", "\n").equals(actual.replaceAll("\r\n", "\n"))) { + File expectedPath = new File(getTempDir(), expectedName); + File actualPath = new File(getTempDir(), + expectedName.replace("expected", "actual")); + Files.write(expected, expectedPath, Charsets.UTF_8); + Files.write(actual, actualPath, Charsets.UTF_8); + // Also update data dir with the current value + if (UPDATE_DIFFERENT_FILES) { + Files.write(actual, new File(getTargetDir(), expectedName), Charsets.UTF_8); + } + System.out.println("The files differ: diff " + expectedPath + " " + + actualPath); + assertEquals("The files differ - see " + expectedPath + " versus " + actualPath, + expected, actual); + } + } + } + + /** Creates a diff of two strings */ + public static String getDiff(String before, String after) { + return getDiff(before.split("\n"), after.split("\n")); + } + + public static String getDiff(String[] before, String[] after) { + // Based on the LCS section in http://introcs.cs.princeton.edu/java/96optimization/ + StringBuilder sb = new StringBuilder(); + + int n = before.length; + int m = after.length; + + // Compute longest common subsequence of x[i..m] and y[j..n] bottom up + int[][] lcs = new int[n + 1][m + 1]; + for (int i = n - 1; i >= 0; i--) { + for (int j = m - 1; j >= 0; j--) { + if (before[i].equals(after[j])) { + lcs[i][j] = lcs[i + 1][j + 1] + 1; + } else { + lcs[i][j] = Math.max(lcs[i + 1][j], lcs[i][j + 1]); + } + } + } + + int i = 0; + int j = 0; + while ((i < n) && (j < m)) { + if (before[i].equals(after[j])) { + i++; + j++; + } else { + sb.append("@@ -"); + sb.append(Integer.toString(i + 1)); + sb.append(" +"); + sb.append(Integer.toString(j + 1)); + sb.append('\n'); + while (i < n && j < m && !before[i].equals(after[j])) { + if (lcs[i + 1][j] >= lcs[i][j + 1]) { + sb.append('-'); + if (!before[i].trim().isEmpty()) { + sb.append(' '); + } + sb.append(before[i]); + sb.append('\n'); + i++; + } else { + sb.append('+'); + if (!after[j].trim().isEmpty()) { + sb.append(' '); + } + sb.append(after[j]); + sb.append('\n'); + j++; + } + } + } + } + + if (i < n || j < m) { + assert i == n || j == m; + sb.append("@@ -"); + sb.append(Integer.toString(i + 1)); + sb.append(" +"); + sb.append(Integer.toString(j + 1)); + sb.append('\n'); + for (; i < n; i++) { + sb.append('-'); + if (!before[i].trim().isEmpty()) { + sb.append(' '); + } + sb.append(before[i]); + sb.append('\n'); + } + for (; j < m; j++) { + sb.append('+'); + if (!after[j].trim().isEmpty()) { + sb.append(' '); + } + sb.append(after[j]); + sb.append('\n'); + } + } + + return sb.toString(); + } + + protected void deleteFile(File dir) { + if (dir.isDirectory()) { + for (File f : dir.listFiles()) { + deleteFile(f); + } + } else if (dir.isFile()) { + assertTrue(dir.getPath(), dir.delete()); + } + } + + protected File makeTestFile(String name, String relative, + final InputStream contents) throws IOException { + return makeTestFile(getTargetDir(), name, relative, contents); + } + + protected File makeTestFile(File dir, String name, String relative, + final InputStream contents) throws IOException { + if (relative != null) { + dir = new File(dir, relative); + if (!dir.exists()) { + boolean mkdir = dir.mkdirs(); + assertTrue(dir.getPath(), mkdir); + } + } else if (!dir.exists()) { + boolean mkdir = dir.mkdirs(); + assertTrue(dir.getPath(), mkdir); + } + File tempFile = new File(dir, name); + if (tempFile.exists()) { + tempFile.delete(); + } + + Files.copy(new InputSupplier<InputStream>() { + @Override + public InputStream getInput() throws IOException { + return contents; + } + }, tempFile); + + return tempFile; + } + + protected File getTestfile(File targetDir, String relativePath) throws IOException { + // Support replacing filenames and paths with a => syntax, e.g. + // dir/file.txt=>dir2/dir3/file2.java + // will read dir/file.txt from the test data and write it into the target + // directory as dir2/dir3/file2.java + + String targetPath = relativePath; + int replaceIndex = relativePath.indexOf("=>"); //$NON-NLS-1$ + if (replaceIndex != -1) { + // foo=>bar + targetPath = relativePath.substring(replaceIndex + "=>".length()); + relativePath = relativePath.substring(0, replaceIndex); + } + + InputStream stream = getTestResource(relativePath, true); + assertNotNull(relativePath + " does not exist", stream); + int index = targetPath.lastIndexOf('/'); + String relative = null; + String name = targetPath; + if (index != -1) { + name = targetPath.substring(index + 1); + relative = targetPath.substring(0, index); + } + + return makeTestFile(targetDir, name, relative, stream); + } + + protected static void addCleanupDir(File dir) { + sCleanDirs.add(dir); + try { + sCleanDirs.add(dir.getCanonicalFile()); + } catch (IOException e) { + fail(e.getLocalizedMessage()); + } + sCleanDirs.add(dir.getAbsoluteFile()); + } + + protected String cleanup(String result) { + List<File> sorted = new ArrayList<File>(sCleanDirs); + // Process dirs in order such that we match longest substrings first + Collections.sort(sorted, new Comparator<File>() { + @Override + public int compare(File file1, File file2) { + String path1 = file1.getPath(); + String path2 = file2.getPath(); + int delta = path2.length() - path1.length(); + if (delta != 0) { + return delta; + } else { + return path1.compareTo(path2); + } + } + }); + + for (File dir : sorted) { + if (result.contains(dir.getPath())) { + result = result.replace(dir.getPath(), "/TESTROOT"); + } + } + + // The output typically contains a few directory/filenames. + // On Windows we need to change the separators to the unix-style + // forward slash to make the test as OS-agnostic as possible. + if (File.separatorChar != '/') { + result = result.replace(File.separatorChar, '/'); + } + + return result; + } +} diff --git a/testutils/tests/.classpath b/testutils/tests/.classpath new file mode 100644 index 0000000..0ac1351 --- /dev/null +++ b/testutils/tests/.classpath @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="src" path="src"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> + <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/> + <classpathentry combineaccessrules="false" kind="src" path="/sdktestutils"/> + <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/guava-tools/guava-13.0.1.jar" sourcepath="/ANDROID_SRC/prebuilts/tools/common/guava-tools/src.zip"/> + <classpathentry kind="output" path="bin"/> +</classpath> diff --git a/testutils/tests/.project b/testutils/tests/.project new file mode 100644 index 0000000..3191084 --- /dev/null +++ b/testutils/tests/.project @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>testutils-tests</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> diff --git a/testutils/tests/Android.mk b/testutils/tests/Android.mk new file mode 100644 index 0000000..e203ab4 --- /dev/null +++ b/testutils/tests/Android.mk @@ -0,0 +1,27 @@ +# Copyright (C) 2012 The Android Open Source Project +# +# 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. + +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) + +# Only compile source java files in this lib. +LOCAL_SRC_FILES := $(call all-java-files-under, src) + +LOCAL_MODULE := sdktestutils-tests +LOCAL_MODULE_TAGS := optional + +LOCAL_JAVA_LIBRARIES := common sdktestutils junit + +include $(BUILD_HOST_JAVA_LIBRARY) diff --git a/testutils/tests/src/com/android/testutils/SdkTestCaseTest.java b/testutils/tests/src/com/android/testutils/SdkTestCaseTest.java new file mode 100644 index 0000000..9ab1a68 --- /dev/null +++ b/testutils/tests/src/com/android/testutils/SdkTestCaseTest.java @@ -0,0 +1,161 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * 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. + */ + +package com.android.testutils; + +import junit.framework.TestCase; + +@SuppressWarnings("javadoc") +public class SdkTestCaseTest extends TestCase { + public void testDiff() throws Exception { + assertEquals( + "", + SdkTestCase.getDiff( + "", + "")); + assertEquals( + "", + SdkTestCase.getDiff( + "aaa", + "aaa")); + assertEquals( + "@@ -1 +1\n" + + "- aaa\n" + + "@@ -2 +1\n" + + "+ bbb\n", + SdkTestCase.getDiff( + "aaa", + "bbb")); + assertEquals( + "@@ -1 +1\n" + + "- this\n" + + "@@ -4 +3\n" + + "+ new\n", + SdkTestCase.getDiff( + "this\n" + + "is\n" + + "a\n" + + "test\n", + + "is\n" + + "a\n" + + "new\n" + + "test\n")); + assertEquals( + "@@ -4 +4\n" + + "- line4\n" + + "- line5\n" + + "@@ -8 +6\n" + + "- line8\n" + + "+ line7.5\n", + SdkTestCase.getDiff( + "line1\n" + + "line2\n" + + "line3\n" + + "line4\n" + + "line5\n" + + "line6\n" + + "line7\n" + + "line8\n" + + "line9\n", + + "line1\n" + + "line2\n" + + "line3\n" + + "line6\n" + + "line7\n" + + "line7.5\n" + + "line9\n")); + assertEquals( + "@@ -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", + + SdkTestCase.getDiff( + "<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" + + "</RelativeLayout>", + + "<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/output\"\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/output\"\n" + + " android:layout_below=\"@+id/output\"\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" + + "</RelativeLayout>")); + } +} |