summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2009-07-17 11:13:48 -0700
committerDianne Hackborn <hackbod@google.com>2009-07-17 16:59:08 -0700
commita53b828635fce8b6b2d3e3377d74d72070056623 (patch)
tree42f4ba9bbf7d8656a4761d6fe5dcd4976cf19369 /tests
parent09a903ab5b8d940605783ae4ee591c0f090a31d1 (diff)
downloadframeworks_base-a53b828635fce8b6b2d3e3377d74d72070056623.zip
frameworks_base-a53b828635fce8b6b2d3e3377d74d72070056623.tar.gz
frameworks_base-a53b828635fce8b6b2d3e3377d74d72070056623.tar.bz2
Add "nodpi" density, and expose a bunch of density-related APIs.
Also update the DpiTest app to use nodpi images, and try to have a mode where it turns off compatibility though it's not quite working.
Diffstat (limited to 'tests')
-rw-r--r--tests/AndroidTests/src/com/android/unit_tests/content/ConfigTest.java2
-rw-r--r--tests/DpiTest/AndroidManifest.xml9
-rw-r--r--tests/DpiTest/res/drawable-nodpi/logonodpi120.pngbin0 -> 5178 bytes
-rw-r--r--tests/DpiTest/res/drawable-nodpi/logonodpi160.pngbin0 -> 8114 bytes
-rw-r--r--tests/DpiTest/res/drawable-nodpi/logonodpi240.pngbin0 -> 13388 bytes
-rw-r--r--tests/DpiTest/src/com/google/android/test/dpi/DpiTestActivity.java37
-rw-r--r--tests/DpiTest/src/com/google/android/test/dpi/DpiTestNoCompatActivity.java23
7 files changed, 68 insertions, 3 deletions
diff --git a/tests/AndroidTests/src/com/android/unit_tests/content/ConfigTest.java b/tests/AndroidTests/src/com/android/unit_tests/content/ConfigTest.java
index e6639d3..a065d70 100644
--- a/tests/AndroidTests/src/com/android/unit_tests/content/ConfigTest.java
+++ b/tests/AndroidTests/src/com/android/unit_tests/content/ConfigTest.java
@@ -133,7 +133,7 @@ public class ConfigTest extends AndroidTestCase {
case DENSITY:
// this is the ratio from the standard
- mMetrics.density = (((float)value)/((float)DisplayMetrics.DEFAULT_DENSITY));
+ mMetrics.density = (((float)value)/((float)DisplayMetrics.DENSITY_DEFAULT));
break;
default:
assert(false);
diff --git a/tests/DpiTest/AndroidManifest.xml b/tests/DpiTest/AndroidManifest.xml
index 64ad7be..ea355a4 100644
--- a/tests/DpiTest/AndroidManifest.xml
+++ b/tests/DpiTest/AndroidManifest.xml
@@ -19,10 +19,15 @@
<uses-sdk android:minSdkVersion="3" android:targetSdkVersion="3" />
<supports-screens android:smallScreens="true" />
<application android:label="DpiTest">
- <activity android:name="DpiTestActivity" android:label="DpiTest">
+ <activity android:name="DpiTestActivity">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ <activity android:name="DpiTestActivityNoCompat" android:label="DpiTestCompat">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
diff --git a/tests/DpiTest/res/drawable-nodpi/logonodpi120.png b/tests/DpiTest/res/drawable-nodpi/logonodpi120.png
new file mode 100644
index 0000000..46bbd5b
--- /dev/null
+++ b/tests/DpiTest/res/drawable-nodpi/logonodpi120.png
Binary files differ
diff --git a/tests/DpiTest/res/drawable-nodpi/logonodpi160.png b/tests/DpiTest/res/drawable-nodpi/logonodpi160.png
new file mode 100644
index 0000000..c23b2ce
--- /dev/null
+++ b/tests/DpiTest/res/drawable-nodpi/logonodpi160.png
Binary files differ
diff --git a/tests/DpiTest/res/drawable-nodpi/logonodpi240.png b/tests/DpiTest/res/drawable-nodpi/logonodpi240.png
new file mode 100644
index 0000000..4d717a8
--- /dev/null
+++ b/tests/DpiTest/res/drawable-nodpi/logonodpi240.png
Binary files differ
diff --git a/tests/DpiTest/src/com/google/android/test/dpi/DpiTestActivity.java b/tests/DpiTest/src/com/google/android/test/dpi/DpiTestActivity.java
index 5a9f3f5..9169025 100644
--- a/tests/DpiTest/src/com/google/android/test/dpi/DpiTestActivity.java
+++ b/tests/DpiTest/src/com/google/android/test/dpi/DpiTestActivity.java
@@ -28,8 +28,38 @@ import android.widget.TextView;
import android.widget.ScrollView;
import android.view.View;
import android.content.Context;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageManager;
+import android.content.res.CompatibilityInfo;
public class DpiTestActivity extends Activity {
+ public DpiTestActivity() {
+ super();
+ init(false);
+ }
+
+ public DpiTestActivity(boolean noCompat) {
+ super();
+ init(noCompat);
+ }
+
+ public void init(boolean noCompat) {
+ try {
+ ApplicationInfo ai = getPackageManager().getApplicationInfo(
+ "com.google.android.test.dpi",
+ PackageManager.GET_SUPPORTS_DENSITIES);
+ if (noCompat) {
+ ai.flags |= ApplicationInfo.FLAG_SUPPORTS_LARGE_SCREENS
+ | ApplicationInfo.FLAG_SUPPORTS_NORMAL_SCREENS
+ | ApplicationInfo.FLAG_SUPPORTS_SMALL_SCREENS;
+ ai.supportsDensities = new int[] { ApplicationInfo.ANY_DENSITY };
+ }
+ getResources().setCompatibilityInfo(new CompatibilityInfo(ai));
+ } catch (PackageManager.NameNotFoundException e) {
+ throw new RuntimeException("ouch", e);
+ }
+ }
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -73,6 +103,13 @@ public class DpiTestActivity extends Activity {
addLabelToRoot(root, "Autoscaled bitmap");
addChildToRoot(root, layout);
+ layout = new LinearLayout(this);
+ addResourceDrawable(layout, R.drawable.logonodpi120);
+ addResourceDrawable(layout, R.drawable.logonodpi160);
+ addResourceDrawable(layout, R.drawable.logonodpi240);
+ addLabelToRoot(root, "No-dpi resource drawable");
+ addChildToRoot(root, layout);
+
setContentView(scrollWrap(root));
}
diff --git a/tests/DpiTest/src/com/google/android/test/dpi/DpiTestNoCompatActivity.java b/tests/DpiTest/src/com/google/android/test/dpi/DpiTestNoCompatActivity.java
new file mode 100644
index 0000000..4d25e08
--- /dev/null
+++ b/tests/DpiTest/src/com/google/android/test/dpi/DpiTestNoCompatActivity.java
@@ -0,0 +1,23 @@
+/*
+ * 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.
+ */
+
+package com.google.android.test.dpi;
+
+public class DpiTestNoCompatActivity extends DpiTestActivity {
+ public DpiTestNoCompatActivity() {
+ super(true);
+ }
+}