aboutsummaryrefslogtreecommitdiffstats
path: root/eclipse/plugins/com.android.ide.eclipse.tests
diff options
context:
space:
mode:
Diffstat (limited to 'eclipse/plugins/com.android.ide.eclipse.tests')
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/AdtProjectTest.java4
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/TestFragment.java.txt15
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/fragmentlayout-expected-navigate13.txt12
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/fragmentlayout-expected-navigate14.txt12
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/fragmentlayout.xml19
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/xml/HyperlinksTest.java26
6 files changed, 87 insertions, 1 deletions
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 3b83bd7..0caeef3 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
@@ -67,6 +67,8 @@ import java.util.Map;
@SuppressWarnings("restriction")
public class AdtProjectTest extends SdkTestCase {
private static final int TARGET_API_LEVEL = 11;
+ 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 */
@@ -689,7 +691,7 @@ public class AdtProjectTest extends SdkTestCase {
}
public String getPackageName() {
- return "com.android.eclipse.tests";
+ return TEST_PROJECT_PACKAGE;
}
public String getActivityName() {
diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/TestFragment.java.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/TestFragment.java.txt
new file mode 100644
index 0000000..0942a19
--- /dev/null
+++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/TestFragment.java.txt
@@ -0,0 +1,15 @@
+package com.android.eclipse.tests;
+
+import android.app.Fragment;
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+public class TestFragment extends Fragment {
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ return null;
+ }
+}
diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/fragmentlayout-expected-navigate13.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/fragmentlayout-expected-navigate13.txt
new file mode 100644
index 0000000..ae30d58
--- /dev/null
+++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/fragmentlayout-expected-navigate13.txt
@@ -0,0 +1,12 @@
+Go To Declaration in fragmentlayout.xml for android:name="com.android.ecl^ipse.tests.TestFragment":
+Open XML Declaration : [com.android.eclipse.tests.TestFragment]
+
+
+After open, the selected text is:
+[^public class TestFragment extends Fragment {
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ return null;
+ }
+}]
diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/fragmentlayout-expected-navigate14.txt b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/fragmentlayout-expected-navigate14.txt
new file mode 100644
index 0000000..0046483
--- /dev/null
+++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/fragmentlayout-expected-navigate14.txt
@@ -0,0 +1,12 @@
+Go To Declaration in fragmentlayout.xml for class="com.and^roid.eclipse.tests.TestFragment":
+Open XML Declaration : [com.android.eclipse.tests.TestFragment]
+
+
+After open, the selected text is:
+[^public class TestFragment extends Fragment {
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ return null;
+ }
+}]
diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/fragmentlayout.xml b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/fragmentlayout.xml
new file mode 100644
index 0000000..758599c
--- /dev/null
+++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/layout/refactoring/testdata/fragmentlayout.xml
@@ -0,0 +1,19 @@
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/home_root"
+ android:orientation="horizontal"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent">
+
+ <LinearLayout android:orientation="vertical"
+ android:layout_width="wrap_content"
+ android:layout_height="fill_parent">
+ <fragment android:name="com.android.eclipse.tests.TestFragment"
+ android:id="@+id/test_fragment"
+ android:layout_marginLeft="20dp"
+ android:layout_weight="1"
+ android:layout_width="fill_parent"
+ android:layout_height="0dp" />
+ <fragment class="com.android.eclipse.tests.TestFragment"
+ android:id="@+id/test_fragment2" />
+ </LinearLayout>
+</LinearLayout>
diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/xml/HyperlinksTest.java b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/xml/HyperlinksTest.java
index 57ca80f..afe6f3b 100644
--- a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/xml/HyperlinksTest.java
+++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/xml/HyperlinksTest.java
@@ -15,6 +15,8 @@
*/
package com.android.ide.eclipse.adt.internal.editors.xml;
+import static com.android.sdklib.SdkConstants.FD_SOURCES;
+
import com.android.ide.common.resources.ResourceFile;
import com.android.ide.eclipse.adt.internal.editors.AndroidXmlEditor;
import com.android.ide.eclipse.adt.internal.editors.layout.refactoring.AdtProjectTest;
@@ -22,6 +24,7 @@ import com.android.ide.eclipse.adt.internal.editors.xml.Hyperlinks.ResourceLink;
import com.android.ide.eclipse.adt.internal.editors.xml.Hyperlinks.XmlResolver;
import org.eclipse.core.resources.IFile;
+import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.Region;
@@ -157,6 +160,24 @@ public class HyperlinksTest extends AdtProjectTest {
"<my.Cust^omView></my.CustomView>");
}
+ public void testNavigate13() throws Exception {
+ // Check jumping to classes pointed to by fragments
+
+ getTestDataFile(getProject(), "TestFragment.java.txt",
+ FD_SOURCES + "/" + TEST_PROJECT_PACKAGE.replace('.', '/') + "/TestFragment.java");
+ checkXmlNavigation("fragmentlayout.xml", "res/layout/fragmentlayout.xml",
+ "android:name=\"com.android.ecl^ipse.tests.TestFragment\"");
+ }
+
+ public void testNavigate14() throws Exception {
+ // Check jumping to classes pointed to by fragments
+
+ getTestDataFile(getProject(), "TestFragment.java.txt",
+ FD_SOURCES + "/" + TEST_PROJECT_PACKAGE.replace('.', '/') + "/TestFragment.java");
+ checkXmlNavigation("fragmentlayout.xml", "res/layout/fragmentlayout.xml",
+ "class=\"com.and^roid.eclipse.tests.TestFragment\"");
+ }
+
// Left to test:
// onClick handling
// class attributes
@@ -248,6 +269,11 @@ public class HyperlinksTest extends AdtProjectTest {
sb.append(" ");
sb.append(initialUrl);
sb.append("\n");
+ } else if (newEditor instanceof JavaEditor) {
+ JavaEditor javaEditor = (JavaEditor) newEditor;
+ document = javaEditor.getDocumentProvider().getDocument(javaEditor.getEditorInput());
+ IRegion range = javaEditor.getHighlightRange();
+ selection = new Point(range.getOffset(), range.getLength());
} else {
fail("Unhandled editor type: " + newEditor.getClass().getName());
return;