am 07559ced: am 59bdf69e: Update Version Numbers for HC MR2 CTS

* commit '07559ceddd4ba849457ba3269485ba481d3b5d29':
  Update Version Numbers for HC MR2 CTS
diff --git a/tests/res/drawable/webp_test.webp b/tests/res/drawable/webp_test.webp
new file mode 100644
index 0000000..7b1009f
--- /dev/null
+++ b/tests/res/drawable/webp_test.webp
Binary files differ
diff --git a/tests/tests/content/src/android/content/cts/AvailableIntentsTest.java b/tests/tests/content/src/android/content/cts/AvailableIntentsTest.java
index bd8c260..45aff4c 100644
--- a/tests/tests/content/src/android/content/cts/AvailableIntentsTest.java
+++ b/tests/tests/content/src/android/content/cts/AvailableIntentsTest.java
@@ -171,4 +171,30 @@
             assertCanBeHandled(intent);
         }
     }
+
+    /**
+     * Test start camera by intent
+     */
+    @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "Intent",
+        args = {java.lang.String.class}
+    )
+    public void testCamera() {
+        PackageManager packageManager = mContext.getPackageManager();
+        if (packageManager.hasSystemFeature(PackageManager.FEATURE_CAMERA)
+                || packageManager.hasSystemFeature(PackageManager.FEATURE_CAMERA_FRONT)) {
+            Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
+            assertCanBeHandled(intent);
+
+            intent.setAction(android.provider.MediaStore.ACTION_VIDEO_CAPTURE);
+            assertCanBeHandled(intent);
+
+            intent.setAction(android.provider.MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA);
+            assertCanBeHandled(intent);
+
+            intent.setAction(android.provider.MediaStore.INTENT_ACTION_VIDEO_CAMERA);
+            assertCanBeHandled(intent);
+        }
+    }
 }
diff --git a/tests/tests/graphics/src/android/graphics/cts/BitmapFactoryTest.java b/tests/tests/graphics/src/android/graphics/cts/BitmapFactoryTest.java
index 4c6259c..fe78477 100644
--- a/tests/tests/graphics/src/android/graphics/cts/BitmapFactoryTest.java
+++ b/tests/tests/graphics/src/android/graphics/cts/BitmapFactoryTest.java
@@ -25,18 +25,23 @@
 import android.content.res.Resources;
 import android.graphics.Bitmap;
 import android.graphics.BitmapFactory;
+import android.graphics.Color;
 import android.graphics.Rect;
+import android.graphics.Bitmap.CompressFormat;
+import android.graphics.Bitmap.Config;
 import android.graphics.BitmapFactory.Options;
 import android.os.ParcelFileDescriptor;
 import android.test.InstrumentationTestCase;
 import android.util.DisplayMetrics;
 
+import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.FileDescriptor;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.OutputStream;
 
 @TestTargetClass(BitmapFactory.class)
 public class BitmapFactoryTest extends InstrumentationTestCase {
@@ -51,6 +56,20 @@
     private int mDefaultDensity;
     private int mTargetDensity;
 
+    // The test images, including baseline JPEG, a PNG, a GIF, a BMP AND a WEBP.
+    private static int[] RES_IDS = new int[] {
+            R.drawable.baseline_jpeg, R.drawable.png_test, R.drawable.gif_test,
+            R.drawable.bmp_test, R.drawable.webp_test
+    };
+    private static String[] NAMES_TEMP_FILES = new String[] {
+        "baseline_temp.jpg", "png_temp.png", "gif_temp.gif",
+        "bmp_temp.bmp", "webp_temp.webp"
+    };
+
+    // The width and height of the above image.
+    private static int WIDTHS[] = new int[] { 1280, 640, 320, 320, 640 };
+    private static int HEIGHTS[] = new int[] { 960, 480, 240, 240, 480 };
+
     @Override
     protected void setUp() throws Exception {
         super.setUp();
@@ -169,6 +188,54 @@
 
     @TestTargetNew(
         level = TestLevel.COMPLETE,
+        method = "decodeStream",
+        args = {java.io.InputStream.class}
+    )
+    public void testDecodeStream3() throws IOException {
+        for (int i = 0; i < RES_IDS.length; ++i) {
+            InputStream is = obtainInputStream(RES_IDS[i]);
+            Bitmap b = BitmapFactory.decodeStream(is);
+            assertNotNull(b);
+            // Test the bitmap size
+            assertEquals(WIDTHS[i], b.getWidth());
+            assertEquals(HEIGHTS[i], b.getHeight());
+        }
+    }
+
+    @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "decodeStream",
+        args = {java.io.InputStream.class}
+    )
+    public void testDecodeStream4() throws IOException {
+        BitmapFactory.Options options = new BitmapFactory.Options();
+        options.inPreferredConfig = Config.ARGB_8888;
+        final int kErrorTol = 16;
+
+        // Decode the PNG & WebP test images. The WebP test image has been encoded from PNG test
+        // image and should have same similar (within some error-tolerance) Bitmap data.
+        InputStream iStreamPng = obtainInputStream(R.drawable.png_test);
+        Bitmap bPng = BitmapFactory.decodeStream(iStreamPng, null, options);
+        assertNotNull(bPng);
+        assertEquals(bPng.getConfig(), Config.ARGB_8888);
+
+        InputStream iStreamWebp1 = obtainInputStream(R.drawable.webp_test);
+        Bitmap bWebp1 = BitmapFactory.decodeStream(iStreamWebp1, null, options);
+        assertNotNull(bWebp1);
+        compareBitmaps(bPng, bWebp1, kErrorTol, true);
+
+        // Compress the PNG image to WebP format (Quality=90) and decode it back.
+        // This will test end-to-end WebP encoding and decoding.
+        ByteArrayOutputStream oStreamWebp = new ByteArrayOutputStream();
+        assertTrue(bPng.compress(CompressFormat.WEBP, 90, oStreamWebp));
+        InputStream iStreamWebp2 = new ByteArrayInputStream(oStreamWebp.toByteArray());
+        Bitmap bWebp2 = BitmapFactory.decodeStream(iStreamWebp2, null, options);
+        assertNotNull(bWebp2);
+        compareBitmaps(bPng, bWebp2, kErrorTol, true);
+    }
+
+    @TestTargetNew(
+        level = TestLevel.COMPLETE,
         method = "decodeFileDescriptor",
         args = {java.io.FileDescriptor.class, android.graphics.Rect.class,
                 android.graphics.BitmapFactory.Options.class}
@@ -240,6 +307,10 @@
         return mRes.openRawResource(R.drawable.start);
     }
 
+    private InputStream obtainInputStream(int resId) {
+        return mRes.openRawResource(resId);
+    }
+
     private FileDescriptor obtainDescriptor(String path) throws IOException {
       File file = new File(path);
       return(ParcelFileDescriptor.open(file,
@@ -266,4 +337,48 @@
         fOutput.close();
         return (file.getPath());
     }
+
+    // Compare expected to actual to see if their diff is less then mseMargin.
+    // lessThanMargin is to indicate whether we expect the mean square error
+    // to be "less than" or "no less than".
+    private void compareBitmaps(Bitmap expected, Bitmap actual,
+            int mseMargin, boolean lessThanMargin) {
+        final int width = expected.getWidth();
+        final int height = expected.getHeight();
+
+        assertEquals("mismatching widths", width, actual.getWidth());
+        assertEquals("mismatching heights", height, actual.getHeight());
+        assertEquals("mismatching configs", expected.getConfig(),
+                actual.getConfig());
+
+        double mse = 0;
+        int[] expectedColors = new int [width * height];
+        int[] actualColors = new int [width * height];
+
+        expected.getPixels(expectedColors, 0, width, 0, 0, width, height);
+        actual.getPixels(actualColors, 0, width, 0, 0, width, height);
+
+        for (int row = 0; row < height; ++row) {
+            for (int col = 0; col < width; ++col) {
+                int idx = row * width + col;
+                mse += distance(expectedColors[idx], actualColors[idx]);
+            }
+        }
+        mse /= width * height;
+
+        if (lessThanMargin) {
+            assertTrue("MSE too large for normal case: " + mse,
+                    mse <= mseMargin);
+        } else {
+            assertFalse("MSE too small for abnormal case: " + mse,
+                    mse <= mseMargin);
+        }
+    }
+
+    private double distance(int expect, int actual) {
+        final int r = Color.red(actual) - Color.red(expect);
+        final int g = Color.green(actual) - Color.green(expect);
+        final int b = Color.blue(actual) - Color.blue(expect);
+        return r * r + g * g + b * b;
+    }
 }
diff --git a/tests/tests/graphics/src/android/graphics/cts/Bitmap_CompressFormatTest.java b/tests/tests/graphics/src/android/graphics/cts/Bitmap_CompressFormatTest.java
index 44c91e3..afe3409 100644
--- a/tests/tests/graphics/src/android/graphics/cts/Bitmap_CompressFormatTest.java
+++ b/tests/tests/graphics/src/android/graphics/cts/Bitmap_CompressFormatTest.java
@@ -37,6 +37,7 @@
     public void testValueOf(){
         assertEquals(CompressFormat.JPEG, CompressFormat.valueOf("JPEG"));
         assertEquals(CompressFormat.PNG, CompressFormat.valueOf("PNG"));
+        assertEquals(CompressFormat.WEBP, CompressFormat.valueOf("WEBP"));
     }
 
     @TestTargets({
@@ -55,13 +56,15 @@
     public void testValues(){
         CompressFormat[] comFormat = CompressFormat.values();
 
-        assertEquals(2, comFormat.length);
+        assertEquals(3, comFormat.length);
         assertEquals(CompressFormat.JPEG, comFormat[0]);
         assertEquals(CompressFormat.PNG, comFormat[1]);
+        assertEquals(CompressFormat.WEBP, comFormat[2]);
 
         //CompressFormat is used as a argument here for all the methods that use it
         Bitmap b = Bitmap.createBitmap(10, 24, Config.ARGB_8888);
         assertTrue(b.compress(CompressFormat.JPEG, 24, new ByteArrayOutputStream()));
         assertTrue(b.compress(CompressFormat.PNG, 24, new ByteArrayOutputStream()));
+        assertTrue(b.compress(CompressFormat.WEBP, 24, new ByteArrayOutputStream()));
     }
 }
diff --git a/tests/tests/telephony/src/android/telephony/cts/SmsManagerTest.java b/tests/tests/telephony/src/android/telephony/cts/SmsManagerTest.java
index c7d9b38..83a5df5 100644
--- a/tests/tests/telephony/src/android/telephony/cts/SmsManagerTest.java
+++ b/tests/tests/telephony/src/android/telephony/cts/SmsManagerTest.java
@@ -79,21 +79,33 @@
                     "44075",    // KDDI
                     "44076",    // KDDI
                     "311870",   // Boost Mobile
-                    "311220"    // USCC
+                    "311220",   // USCC
+                    "302720",   // Rogers
+                    "30272",    // Rogers
+                    "302370",   // Fido
+                    "30237"     // Fido
             );
 
     // List of network operators that doesn't support Data(binary) SMS message
     private static final List<String> UNSUPPORT_DATA_SMS_MESSAGES =
             Arrays.asList(
                     "44010",    // NTT DOCOMO
-                    "44020"     // SBM
+                    "44020",    // SBM
+                    "302720",   // Rogers
+                    "30272",    // Rogers
+                    "302370",   // Fido
+                    "30237"     // Fido
             );
 
     // List of network operators that doesn't support Maltipart SMS message
     private static final List<String> UNSUPPORT_MULTIPART_SMS_MESSAGES =
             Arrays.asList(
                     "44010",    // NTT DOCOMO
-                    "44020"     // SBM
+                    "44020",    // SBM
+                    "302720",   // Rogers
+                    "30272",    // Rogers
+                    "302370",   // Fido
+                    "30237"     // Fido
             );
 
     private TelephonyManager mTelephonyManager;
@@ -118,7 +130,7 @@
         super.setUp();
         mTelephonyManager =
             (TelephonyManager) getContext().getSystemService(Context.TELEPHONY_SERVICE);
-        mPackageManager = getContext().getPackageManager();
+        mPackageManager = mContext.getPackageManager();
         mDestAddr = mTelephonyManager.getLine1Number();
         mText = "This is a test message";
 
diff --git a/tests/tests/widget/src/android/widget/cts/GridViewTest.java b/tests/tests/widget/src/android/widget/cts/GridViewTest.java
index 7932e71..802aa96 100644
--- a/tests/tests/widget/src/android/widget/cts/GridViewTest.java
+++ b/tests/tests/widget/src/android/widget/cts/GridViewTest.java
@@ -890,12 +890,6 @@
                 R.drawable.animated, R.drawable.black,
                 R.drawable.blue, R.drawable.failed,
                 R.drawable.pass, R.drawable.red,
-                R.drawable.failed, R.drawable.pass,
-                R.drawable.animated, R.drawable.black,
-                R.drawable.blue, R.drawable.red,
-                R.drawable.animated, R.drawable.black,
-                R.drawable.blue, R.drawable.failed,
-                R.drawable.pass, R.drawable.red,
         };
 
         private final DataSetObservable mDataSetObservable = new DataSetObservable();