diff options
author | Raphael <raphael@google.com> | 2012-01-09 22:49:33 -0800 |
---|---|---|
committer | Raphael <raphael@google.com> | 2012-01-19 14:33:04 -0800 |
commit | e50549f54810c29bffc681e39d33158ab2a8f26e (patch) | |
tree | c592996c14cecefb19dd85802f62074db8716f84 /eclipse/plugins/com.android.ide.eclipse.tests | |
parent | 7d7b8fb5d49f986d0e01619829ae3f4f82df46ce (diff) | |
download | sdk-e50549f54810c29bffc681e39d33158ab2a8f26e.zip sdk-e50549f54810c29bffc681e39d33158ab2a8f26e.tar.gz sdk-e50549f54810c29bffc681e39d33158ab2a8f26e.tar.bz2 |
ADT: Change LayoutEditor to use new editor delegates.
Change-Id: I5624d8f5c393a74a808d98e465f0ebc6db91d741
Diffstat (limited to 'eclipse/plugins/com.android.ide.eclipse.tests')
9 files changed, 72 insertions, 54 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/AndroidContentAssistTest.java b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/AndroidContentAssistTest.java index 0757166..f46f7e2 100644 --- a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/AndroidContentAssistTest.java +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/AndroidContentAssistTest.java @@ -25,10 +25,13 @@ import static com.android.sdklib.SdkConstants.FD_RES; import com.android.ide.eclipse.adt.AdtPlugin; import com.android.ide.eclipse.adt.internal.editors.animator.AnimationContentAssist; +import com.android.ide.eclipse.adt.internal.editors.animator.AnimationEditorDelegate; import com.android.ide.eclipse.adt.internal.editors.color.ColorContentAssist; +import com.android.ide.eclipse.adt.internal.editors.color.ColorEditorDelegate; import com.android.ide.eclipse.adt.internal.editors.drawable.DrawableContentAssist; +import com.android.ide.eclipse.adt.internal.editors.drawable.DrawableEditorDelegate; import com.android.ide.eclipse.adt.internal.editors.layout.LayoutContentAssist; -import com.android.ide.eclipse.adt.internal.editors.layout.LayoutEditor; +import com.android.ide.eclipse.adt.internal.editors.layout.LayoutEditorDelegate; import com.android.ide.eclipse.adt.internal.editors.layout.refactoring.AdtProjectTest; import com.android.ide.eclipse.adt.internal.editors.manifest.ManifestContentAssist; import com.android.ide.eclipse.adt.internal.editors.manifest.ManifestEditor; @@ -770,34 +773,34 @@ public class AndroidContentAssistTest extends AdtProjectTest { private void checkLayoutCompletion(String name, String caretLocation) throws Exception { IFile file = getLayoutFile(getProject(), name); - IDE.setDefaultEditor(file, LayoutEditor.ID); + IDE.setDefaultEditor(file, LayoutEditorDelegate.OLD_STANDALONE_EDITOR_ID); checkCompletion(name, file, caretLocation, new LayoutContentAssist()); } private void checkColorCompletion(String name, String caretLocation) throws Exception { IFile file = getTestDataFile(getProject(), name, FD_RES + "/" + FD_RES_COLOR + "/" + name); - IDE.setDefaultEditor(file, AndroidXmlCommonEditor.ID); + IDE.setDefaultEditor(file, ColorEditorDelegate.OLD_STANDALONE_EDITOR_ID); checkCompletion(name, file, caretLocation, new ColorContentAssist()); } private void checkAnimCompletion(String name, String caretLocation) throws Exception { IFile file = getTestDataFile(getProject(), name, FD_RES + "/" + FD_RES_ANIM + "/" + name); - IDE.setDefaultEditor(file, AndroidXmlCommonEditor.ID); + IDE.setDefaultEditor(file, AnimationEditorDelegate.OLD_STANDALONE_EDITOR_ID); checkCompletion(name, file, caretLocation, new AnimationContentAssist()); } private void checkAnimatorCompletion(String name, String caretLocation) throws Exception { IFile file = getTestDataFile(getProject(), name, FD_RES + "/" + FD_RES_ANIMATOR + "/" + name); - IDE.setDefaultEditor(file, AndroidXmlCommonEditor.ID); + IDE.setDefaultEditor(file, AnimationEditorDelegate.OLD_STANDALONE_EDITOR_ID); checkCompletion(name, file, caretLocation, new AnimationContentAssist()); } private void checkDrawableCompletion(String name, String caretLocation) throws Exception { IFile file = getTestDataFile(getProject(), name, FD_RES + "/" + FD_RES_DRAWABLE + "/" + name); - IDE.setDefaultEditor(file, AndroidXmlCommonEditor.ID); + IDE.setDefaultEditor(file, DrawableEditorDelegate.OLD_STANDALONE_EDITOR_ID); checkCompletion(name, file, caretLocation, new DrawableContentAssist()); } 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 9e3339d..57bb6e5 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 @@ -20,9 +20,10 @@ import static com.android.AndroidConstants.FD_RES_VALUES; import static com.android.sdklib.SdkConstants.FD_RES; import com.android.ide.eclipse.adt.AdtPlugin; +import com.android.ide.eclipse.adt.internal.editors.AndroidXmlCommonEditor; import com.android.ide.eclipse.adt.internal.editors.descriptors.AttributeDescriptor; import com.android.ide.eclipse.adt.internal.editors.descriptors.ElementDescriptor; -import com.android.ide.eclipse.adt.internal.editors.layout.LayoutEditor; +import com.android.ide.eclipse.adt.internal.editors.layout.LayoutEditorDelegate; import com.android.ide.eclipse.adt.internal.editors.layout.descriptors.ViewElementDescriptor; import com.android.ide.eclipse.adt.internal.editors.layout.uimodel.UiViewElementNode; import com.android.ide.eclipse.adt.internal.editors.uimodel.UiDocumentNode; @@ -607,54 +608,67 @@ public class AdtProjectTest extends SdkTestCase { } /** Special editor context set on the model to be rendered */ - protected static class TestLayoutEditor extends LayoutEditor { - private final IFile mFile; - private final IStructuredDocument mStructuredDocument; - private UiDocumentNode mUiRootNode; + protected static class TestLayoutEditorDelegate extends LayoutEditorDelegate { - public TestLayoutEditor(IFile file, IStructuredDocument structuredDocument, + public TestLayoutEditorDelegate( + IFile file, + IStructuredDocument structuredDocument, UiDocumentNode uiRootNode) { - mFile = file; - mStructuredDocument = structuredDocument; - mUiRootNode = uiRootNode; + super(new TestAndroidXmlCommonEditor(file, structuredDocument, uiRootNode)); } - @Override - public IFile getInputFile() { - return mFile; - } + static class TestAndroidXmlCommonEditor extends AndroidXmlCommonEditor { - @Override - public IProject getProject() { - return mFile.getProject(); - } + private final IFile mFile; + private final IStructuredDocument mStructuredDocument; + private UiDocumentNode mUiRootNode; - @Override - public IStructuredDocument getStructuredDocument() { - return mStructuredDocument; - } + TestAndroidXmlCommonEditor( + IFile file, + IStructuredDocument structuredDocument, + UiDocumentNode uiRootNode) { + mFile = file; + mStructuredDocument = structuredDocument; + mUiRootNode = uiRootNode; + } - @Override - public UiDocumentNode getUiRootNode() { - return mUiRootNode; - } + @Override + public IFile getInputFile() { + return mFile; + } - @Override - public void editorDirtyStateChanged() { - } + @Override + public IProject getProject() { + return mFile.getProject(); + } - @Override - public IStructuredModel getModelForRead() { - IModelManager mm = StructuredModelManager.getModelManager(); - if (mm != null) { - try { - return mm.getModelForRead(mFile); - } catch (Exception e) { - fail(e.toString()); - } + @Override + public IStructuredDocument getStructuredDocument() { + return mStructuredDocument; } - return null; + @Override + public UiDocumentNode getUiRootNode() { + return mUiRootNode; + } + + @Override + public void editorDirtyStateChanged() { + } + + @Override + public IStructuredModel getModelForRead() { + IModelManager mm = StructuredModelManager.getModelManager(); + if (mm != null) { + try { + return mm.getModelForRead(mFile); + } catch (Exception e) { + fail(e.toString()); + } + } + + return null; + } } } 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 bcbf461..baa7265 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 @@ -111,7 +111,7 @@ public class ChangeLayoutRefactoringTest extends RefactoringTest { boolean flatten, String initialAttributes) throws Exception { IFile file = getLayoutFile(getProject(), basename); TestContext info = setupTestContext(file, basename); - TestLayoutEditor layoutEditor = info.mLayoutEditor; + TestLayoutEditorDelegate layoutEditor = info.mLayoutEditorDelegate; CanvasViewInfo rootView = info.mRootView; Element element = info.mElement; diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/ChangeViewRefactoringTest.java b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/ChangeViewRefactoringTest.java index 80307d2..7ed43e7 100644 --- a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/ChangeViewRefactoringTest.java +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/ChangeViewRefactoringTest.java @@ -46,7 +46,7 @@ public class ChangeViewRefactoringTest extends RefactoringTest { IFile file = getLayoutFile(getProject(), basename); TestContext info = setupTestContext(file, basename); - TestLayoutEditor layoutEditor = info.mLayoutEditor; + TestLayoutEditorDelegate layoutEditor = info.mLayoutEditorDelegate; List<Element> selectedElements = getElements(info.mElement, ids); ChangeViewRefactoring refactoring = new ChangeViewRefactoring(selectedElements, diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/ExtractIncludeRefactoringTest.java b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/ExtractIncludeRefactoringTest.java index d2e1073..94a0ecc 100644 --- a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/ExtractIncludeRefactoringTest.java +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/ExtractIncludeRefactoringTest.java @@ -137,7 +137,7 @@ public class ExtractIncludeRefactoringTest extends RefactoringTest { IFile file = getLayoutFile(getProject(), basename); TestContext info = setupTestContext(file, basename); - TestLayoutEditor layoutEditor = info.mLayoutEditor; + TestLayoutEditorDelegate layoutEditor = info.mLayoutEditorDelegate; List<Element> selectedElements = getElements(info.mElement, ids); ExtractIncludeRefactoring refactoring = new ExtractIncludeRefactoring(selectedElements, diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/ExtractStyleRefactoringTest.java b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/ExtractStyleRefactoringTest.java index 65c7d6f..b630865 100644 --- a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/ExtractStyleRefactoringTest.java +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/ExtractStyleRefactoringTest.java @@ -134,7 +134,7 @@ public class ExtractStyleRefactoringTest extends RefactoringTest { IFile file = getLayoutFile(getProject(), basename); TestContext info = setupTestContext(file, basename); - TestLayoutEditor layoutEditor = info.mLayoutEditor; + TestLayoutEditorDelegate layoutEditor = info.mLayoutEditorDelegate; List<Element> selectedElements = getElements(info.mElement, ids); // Open the file such that ModelManager.getExistingModelForRead() in DomUtilities @@ -161,7 +161,7 @@ public class ExtractStyleRefactoringTest extends RefactoringTest { int endOffset = getCaretOffset(file, endCaretLocation); TestContext info = setupTestContext(file, basename); - TestLayoutEditor layoutEditor = info.mLayoutEditor; + TestLayoutEditorDelegate layoutEditor = info.mLayoutEditorDelegate; // Open the file such that ModelManager.getExistingModelForRead() in DomUtilities // will succeed 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 c525e30..ea8427e 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 @@ -289,7 +289,8 @@ public class RefactoringTest extends AdtProjectTest { UiViewElementNode model = createModel(null, element); ViewInfo info = createInfos(model, relativePath); CanvasViewInfo rootView = CanvasViewInfo.create(info, true /* layoutlib5 */).getFirst(); - TestLayoutEditor layoutEditor = new TestLayoutEditor(file, structuredDocument, null); + TestLayoutEditorDelegate layoutEditor = + new TestLayoutEditorDelegate(file, structuredDocument, null); TestContext testInfo = createTestContext(); testInfo.mFile = file; @@ -300,7 +301,7 @@ public class RefactoringTest extends AdtProjectTest { testInfo.mUiModel = model; testInfo.mViewInfo = info; testInfo.mRootView = rootView; - testInfo.mLayoutEditor = layoutEditor; + testInfo.mLayoutEditorDelegate = layoutEditor; return testInfo; } @@ -318,7 +319,7 @@ public class RefactoringTest extends AdtProjectTest { protected UiViewElementNode mUiModel; protected ViewInfo mViewInfo; protected CanvasViewInfo mRootView; - protected TestLayoutEditor mLayoutEditor; + protected TestLayoutEditorDelegate mLayoutEditorDelegate; } @Override diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/UnwrapRefactoringTest.java b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/UnwrapRefactoringTest.java index 0541a63..e03ea9e 100644 --- a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/UnwrapRefactoringTest.java +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/UnwrapRefactoringTest.java @@ -43,7 +43,7 @@ public class UnwrapRefactoringTest extends RefactoringTest { private void checkRefactoring(String basename, String id) throws Exception { IFile file = getLayoutFile(getProject(), basename); TestContext info = setupTestContext(file, basename); - TestLayoutEditor layoutEditor = info.mLayoutEditor; + TestLayoutEditorDelegate layoutEditor = info.mLayoutEditorDelegate; List<Element> selectedElements = getElements(info.mElement, id); assertEquals(1, selectedElements.size()); diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/WrapInRefactoringTest.java b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/WrapInRefactoringTest.java index 26d908b..219dabe 100644 --- a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/WrapInRefactoringTest.java +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/WrapInRefactoringTest.java @@ -47,7 +47,7 @@ public class WrapInRefactoringTest extends RefactoringTest { IFile file = getLayoutFile(getProject(), basename); TestContext info = setupTestContext(file, basename); - TestLayoutEditor layoutEditor = info.mLayoutEditor; + TestLayoutEditorDelegate layoutEditor = info.mLayoutEditorDelegate; List<Element> selectedElements = getElements(info.mElement, ids); WrapInRefactoring refactoring = new WrapInRefactoring(selectedElements, |