aboutsummaryrefslogtreecommitdiffstats
path: root/eclipse/plugins/com.android.ide.eclipse.tests
diff options
context:
space:
mode:
authorTor Norbye <tnorbye@google.com>2011-04-15 14:28:27 -0700
committerTor Norbye <tnorbye@google.com>2011-04-18 14:59:22 -0700
commitab02e0845abebb9dd36e6e3cf9a2b5ecfb34bdaa (patch)
treea2d75e87db1b59c2496b0011b55660632ee2ea1e /eclipse/plugins/com.android.ide.eclipse.tests
parentb0f50e6ac987902891c2bbc6bfa4f51a46e31b73 (diff)
downloadsdk-ab02e0845abebb9dd36e6e3cf9a2b5ecfb34bdaa.zip
sdk-ab02e0845abebb9dd36e6e3cf9a2b5ecfb34bdaa.tar.gz
sdk-ab02e0845abebb9dd36e6e3cf9a2b5ecfb34bdaa.tar.bz2
Cache resource resolver and manifest info
This changeset adds caching of the ResourceResolver in the layout editor such that it can be reused for successive rendering requests as long as the configuration does not change. It also adds caching of the manifest icon and label; these are invalidated whenever the manifest file is updated and saved. Change-Id: Idbf77fd96fa60a4ac24e06bbecae882829a8b812
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.java3
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/manifest/ManifestInfoTest.java33
2 files changed, 36 insertions, 0 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 aabe9f7..ead55f9 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
@@ -89,6 +89,9 @@ public class AdtProjectTest extends SdkTestCase {
super.setUp();
// Prevent preview icon computation during plugin test to make test faster
+ if (AdtPlugin.getDefault() == null) {
+ fail("This test must be run as an Eclipse plugin test, not a plain JUnit test!");
+ }
AdtPrefs.getPrefs().setPaletteModes("ICON_TEXT"); //$NON-NLS-1$
getProject();
diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/manifest/ManifestInfoTest.java b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/manifest/ManifestInfoTest.java
index 66a2482..5eba812 100644
--- a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/manifest/ManifestInfoTest.java
+++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/manifest/ManifestInfoTest.java
@@ -166,7 +166,40 @@ public class ManifestInfoTest extends AdtProjectTest {
}
+ public void testGetApplicationLabelAndIcon() throws Exception {
+ ManifestInfo info = getManifestInfo(
+ "<manifest xmlns:android='http://schemas.android.com/apk/res/android'\n" +
+ " package='com.android.unittest'>\n" +
+ " <application android:icon=\"@drawable/icon\"\n" +
+ " android:label=\"@string/app_name\">\n" +
+ " </application>\n" +
+ "" +
+ "</manifest>\n");
+ Map<String, String> map = info.getActivityThemes();
+ assertEquals(map.toString(), 0, map.size());
+ assertEquals("com.android.unittest", info.getPackage());
+
+ assertEquals("Theme", ResourceHelper.styleToTheme(info.getDefaultTheme(null, NORMAL)));
+ assertEquals("@drawable/icon", info.getApplicationIcon());
+ assertEquals("@string/app_name", info.getApplicationLabel());
+ }
+ public void testGetApplicationNoLabelOrIcon() throws Exception {
+ ManifestInfo info = getManifestInfo(
+ "<manifest xmlns:android='http://schemas.android.com/apk/res/android'\n" +
+ " package='com.android.unittest'>\n" +
+ " <application>\n" +
+ " </application>\n" +
+ "" +
+ "</manifest>\n");
+ Map<String, String> map = info.getActivityThemes();
+ assertEquals(map.toString(), 0, map.size());
+ assertEquals("com.android.unittest", info.getPackage());
+
+ assertEquals("Theme", ResourceHelper.styleToTheme(info.getDefaultTheme(null, NORMAL)));
+ assertNull(info.getApplicationIcon());
+ assertNull(info.getApplicationLabel());
+ }
private ManifestInfo getManifestInfo(String manifestContents) throws Exception {
InputStream bstream = new ByteArrayInputStream(