Revert "DO NOT MERGE: Fix Bitmap and NinePatch drawable tests for non-mdpi devices"

This reverts commit 2ef9c1b13a1354a1ca502cbdf00308b8c347c7a5.

Change-Id: I56942889959365d40b18b68a15f4c8ce5a6e63c7
diff --git a/tests/tests/graphics/src/android/graphics/drawable/cts/BitmapDrawableTest.java b/tests/tests/graphics/src/android/graphics/drawable/cts/BitmapDrawableTest.java
index c2c90e5..88e7acb 100644
--- a/tests/tests/graphics/src/android/graphics/drawable/cts/BitmapDrawableTest.java
+++ b/tests/tests/graphics/src/android/graphics/drawable/cts/BitmapDrawableTest.java
@@ -316,48 +316,29 @@
 
         InputStream source = mContext.getResources().openRawResource(R.drawable.size_48x48);
         bitmapDrawable = new BitmapDrawable(source);
-        bitmapDrawable.setTargetDensity(bitmapDrawable.getBitmap().getDensity());
+        bitmapDrawable.setTargetDensity(mContext.getResources().getDisplayMetrics().densityDpi);
         assertEquals(48, bitmapDrawable.getIntrinsicWidth());
         assertEquals(48, bitmapDrawable.getIntrinsicHeight());
     }
 
     @SuppressWarnings("deprecation")
     public void testSetTargetDensity() {
-        int sourceWidth, targetWidth;
-        int sourceHeight, targetHeight;
-        int sourceDensity, targetDensity;
-        BitmapDrawable bitmapDrawable;
-        Bitmap bitmap;
+        BitmapDrawable bitmapDrawable = new BitmapDrawable();
 
-        sourceWidth = 200;
-        sourceHeight = 300;
-        bitmap = Bitmap.createBitmap(sourceWidth, sourceHeight, Config.RGB_565);
+        Bitmap bitmap = Bitmap.createBitmap(200, 300, Config.RGB_565);
         Canvas canvas = new Canvas(bitmap);
         bitmapDrawable = new BitmapDrawable(bitmap);
-        sourceDensity = bitmap.getDensity();
-        targetDensity = canvas.getDensity();
-        bitmapDrawable.setTargetDensity(targetDensity);
-        targetWidth = DrawableTestUtils.scaleBitmapFromDensity(
-                sourceWidth, sourceDensity, targetDensity);
-        targetHeight = DrawableTestUtils.scaleBitmapFromDensity(
-                sourceHeight, sourceDensity, targetDensity);
-        assertEquals(targetWidth, bitmapDrawable.getIntrinsicWidth());
-        assertEquals(targetHeight, bitmapDrawable.getIntrinsicHeight());
+        bitmapDrawable.setTargetDensity(canvas.getDensity());
+        assertEquals(200, bitmapDrawable.getIntrinsicWidth());
+        assertEquals(300, bitmapDrawable.getIntrinsicHeight());
 
-        sourceWidth = 48;
-        sourceHeight = 48;
+        DisplayMetrics disMetrics = new DisplayMetrics();
+        disMetrics = getInstrumentation().getTargetContext().getResources().getDisplayMetrics();
         InputStream source = mContext.getResources().openRawResource(R.drawable.size_48x48);
         bitmapDrawable = new BitmapDrawable(source);
-        bitmap = bitmapDrawable.getBitmap();
-        sourceDensity = bitmap.getDensity();
-        targetDensity = sourceDensity * 2;
-        bitmapDrawable.setTargetDensity(targetDensity);
-        targetWidth = DrawableTestUtils.scaleBitmapFromDensity(
-                sourceWidth, sourceDensity, targetDensity);
-        targetHeight = DrawableTestUtils.scaleBitmapFromDensity(
-                sourceHeight, sourceDensity, targetDensity);
-        assertEquals(targetWidth, bitmapDrawable.getIntrinsicWidth());
-        assertEquals(targetHeight, bitmapDrawable.getIntrinsicHeight());
+        bitmapDrawable.setTargetDensity(disMetrics.densityDpi);
+        assertEquals(48, bitmapDrawable.getIntrinsicWidth());
+        assertEquals(48, bitmapDrawable.getIntrinsicHeight());
     }
 
     @SuppressWarnings("deprecation")
diff --git a/tests/tests/graphics/src/android/graphics/drawable/cts/DrawableTestUtils.java b/tests/tests/graphics/src/android/graphics/drawable/cts/DrawableTestUtils.java
index 4ddc714..a0fa634 100644
--- a/tests/tests/graphics/src/android/graphics/drawable/cts/DrawableTestUtils.java
+++ b/tests/tests/graphics/src/android/graphics/drawable/cts/DrawableTestUtils.java
@@ -85,41 +85,4 @@
         }
         return attrs;
     }
-
-    public static XmlResourceParser getResourceParser(Resources res, int resId)
-            throws XmlPullParserException, IOException {
-        final XmlResourceParser parser = res.getXml(resId);
-        int type;
-        while ((type = parser.next()) != XmlPullParser.START_TAG
-                && type != XmlPullParser.END_DOCUMENT) {
-            // Empty loop
-        }
-        return parser;
-    }
-
-    public static void setResourcesDensity(Resources res, int densityDpi) {
-        final Configuration config = new Configuration();
-        config.setTo(res.getConfiguration());
-        config.densityDpi = densityDpi;
-        res.updateConfiguration(config, null);
-    }
-
-    /**
-     * Implements scaling as used by the Bitmap class. Resulting values are
-     * rounded up (as distinct from resource scaling, which truncates or rounds
-     * to the nearest pixel).
-     *
-     * @param size the pixel size to scale
-     * @param sdensity the source density that corresponds to the size
-     * @param tdensity the target density
-     * @return the pixel size scaled for the target density
-     */
-    public static int scaleBitmapFromDensity(int size, int sdensity, int tdensity) {
-        if (sdensity == 0 || tdensity == 0 || sdensity == tdensity) {
-            return size;
-        }
-
-        // Scale by tdensity / sdensity, rounding up.
-        return ((size * tdensity) + (sdensity >> 1)) / sdensity;
-    }
 }
diff --git a/tests/tests/graphics/src/android/graphics/drawable/cts/NinePatchDrawableTest.java b/tests/tests/graphics/src/android/graphics/drawable/cts/NinePatchDrawableTest.java
index 195b7d5..720397c 100644
--- a/tests/tests/graphics/src/android/graphics/drawable/cts/NinePatchDrawableTest.java
+++ b/tests/tests/graphics/src/android/graphics/drawable/cts/NinePatchDrawableTest.java
@@ -311,23 +311,15 @@
     }
 
     public void testInflate() throws XmlPullParserException, IOException {
-        int sourceWidth = 80;
-        int sourceHeight = 120;
-        int[] colors = new int[sourceWidth * sourceHeight];
-        Bitmap bitmap = Bitmap.createBitmap(
-                colors, sourceWidth, sourceHeight, Bitmap.Config.RGB_565);
-        NinePatchDrawable ninePatchDrawable = new NinePatchDrawable(
-                mResources, bitmap, new byte[1000], null, "TESTNAME");
+        final int width = 80;
+        final int height = 120;
+        final int[] COLOR = new int[width * height];
+        Bitmap bitmap = Bitmap.createBitmap(COLOR, width, height, Bitmap.Config.RGB_565);
+        NinePatchDrawable ninePatchDrawable =
+            new NinePatchDrawable(mResources, bitmap, new byte[1000], null, "TESTNAME");
 
-        int sourceDensity = bitmap.getDensity();
-        int targetDensity = mResources.getDisplayMetrics().densityDpi;
-        int targetWidth = DrawableTestUtils.scaleBitmapFromDensity(
-                sourceWidth, sourceDensity, targetDensity);
-        int targetHeight = DrawableTestUtils.scaleBitmapFromDensity(
-                sourceHeight, sourceDensity, targetDensity);
-        assertEquals(targetWidth, ninePatchDrawable.getIntrinsicWidth());
-        assertEquals(targetHeight, ninePatchDrawable.getIntrinsicHeight());
-
+        assertEquals(height, ninePatchDrawable.getIntrinsicHeight());
+        assertEquals(width, ninePatchDrawable.getIntrinsicWidth());
         XmlResourceParser parser = mResources.getXml(R.drawable.ninepatchdrawable);
         int type;
         while ((type = parser.next()) != XmlPullParser.END_DOCUMENT
@@ -337,8 +329,8 @@
         ninePatchDrawable.inflate(mResources, parser, attrs);
 
         assertTrue(ninePatchDrawable.getPaint().isDither());
-        assertTrue(sourceHeight != ninePatchDrawable.getIntrinsicHeight());
-        assertTrue(sourceWidth != ninePatchDrawable.getIntrinsicWidth());
+        assertTrue(height != ninePatchDrawable.getIntrinsicHeight());
+        assertTrue(width != ninePatchDrawable.getIntrinsicWidth());
     }
 
     public void testMutate() {