Merge "Make CookieSyncManagerTest use stricter cookie format."
diff --git a/tests/tests/media/src/android/media/cts/CamcorderProfileTest.java b/tests/tests/media/src/android/media/cts/CamcorderProfileTest.java
index 63f5465..17e2481 100644
--- a/tests/tests/media/src/android/media/cts/CamcorderProfileTest.java
+++ b/tests/tests/media/src/android/media/cts/CamcorderProfileTest.java
@@ -22,6 +22,8 @@
 import dalvik.annotation.TestTargets;
 
 import android.hardware.Camera;
+import android.hardware.Camera.Parameters;
+import android.hardware.Camera.Size;
 import android.media.CamcorderProfile;
 import android.test.AndroidTestCase;
 import android.util.Log;
@@ -42,7 +44,7 @@
         }
     }
 
-    private void checkProfile(CamcorderProfile profile) {
+    private void checkProfile(CamcorderProfile profile, List<Size> videoSizes) {
         Log.v(TAG, String.format("profile: duration=%d, quality=%d, " +
             "fileFormat=%d, videoCodec=%d, videoBitRate=%d, videoFrameRate=%d, " +
             "videoFrameWidth=%d, videoFrameHeight=%d, audioCodec=%d, " +
@@ -81,6 +83,9 @@
         assertTrue(profile.audioBitRate > 0);
         assertTrue(profile.audioSampleRate > 0);
         assertTrue(profile.audioChannels > 0);
+        assertTrue(isSizeSupported(profile.videoFrameWidth,
+                                   profile.videoFrameHeight,
+                                   videoSizes));
     }
 
     private void assertProfileEquals(CamcorderProfile expectedProfile,
@@ -138,8 +143,13 @@
     // Checks if the existing specific profiles have the correct dimensions.
     // Also checks that the mimimum quality specific profile matches the low profile and
     // similarly that the maximum quality specific profile matches the high profile.
-    private void checkSpecificProfiles(int cameraId,
-            CamcorderProfile low, CamcorderProfile high, int[] specificQualities) {
+    private void checkSpecificProfiles(
+            int cameraId,
+            CamcorderProfile low,
+            CamcorderProfile high,
+            int[] specificQualities,
+            List<Size> videoSizes) {
+
         CamcorderProfile minProfile = null;
         CamcorderProfile maxProfile = null;
 
@@ -149,6 +159,10 @@
                 CamcorderProfile profile = getWithOptionalId(quality, cameraId);
                 checkSpecificProfileDimensions(profile, quality);
 
+                assertTrue(isSizeSupported(profile.videoFrameWidth,
+                                           profile.videoFrameHeight,
+                                           videoSizes));
+
                 if (minProfile == null) {
                     minProfile = profile;
                 }
@@ -166,6 +180,7 @@
 
         assertProfileEquals(low, minProfile);
         assertProfileEquals(high, maxProfile);
+
     }
 
     private void checkGet(int cameraId) {
@@ -173,19 +188,21 @@
                    ? "Checking get without id"
                    : "Checking get with id = " + cameraId);
 
+        final List<Size> videoSizes = getSupportedVideoSizes(cameraId);
+
         CamcorderProfile lowProfile =
             getWithOptionalId(CamcorderProfile.QUALITY_LOW, cameraId);
         CamcorderProfile highProfile =
             getWithOptionalId(CamcorderProfile.QUALITY_HIGH, cameraId);
-        checkProfile(lowProfile);
-        checkProfile(highProfile);
+        checkProfile(lowProfile, videoSizes);
+        checkProfile(highProfile, videoSizes);
 
         CamcorderProfile lowTimeLapseProfile =
             getWithOptionalId(CamcorderProfile.QUALITY_TIME_LAPSE_LOW, cameraId);
         CamcorderProfile highTimeLapseProfile =
             getWithOptionalId(CamcorderProfile.QUALITY_TIME_LAPSE_HIGH, cameraId);
-        checkProfile(lowTimeLapseProfile);
-        checkProfile(highTimeLapseProfile);
+        checkProfile(lowTimeLapseProfile, null);
+        checkProfile(highTimeLapseProfile, null);
 
         int[] specificProfileQualities = {CamcorderProfile.QUALITY_QCIF,
                                           CamcorderProfile.QUALITY_CIF,
@@ -200,9 +217,9 @@
                                                    CamcorderProfile.QUALITY_TIME_LAPSE_1080P};
 
         checkSpecificProfiles(cameraId, lowProfile, highProfile,
-                specificProfileQualities);
+                specificProfileQualities, videoSizes);
         checkSpecificProfiles(cameraId, lowTimeLapseProfile, highTimeLapseProfile,
-                specificTimeLapseProfileQualities);
+                specificTimeLapseProfileQualities, null);
     }
 
     @TestTargets({
@@ -229,4 +246,27 @@
             checkGet(cameraId);
         }
     }
+
+    private List<Size> getSupportedVideoSizes(int cameraId) {
+        Camera camera = (cameraId == -1)? Camera.open(): Camera.open(cameraId);
+        Parameters parameters = camera.getParameters();
+        List<Size> videoSizes = parameters.getSupportedVideoSizes();
+        if (videoSizes == null) {
+            videoSizes = parameters.getSupportedPreviewSizes();
+            assertNotNull(videoSizes);
+        }
+        camera.release();
+        return videoSizes;
+    }
+
+    private boolean isSizeSupported(int width, int height, List<Size> sizes) {
+        if (sizes == null) return true;
+
+        for (Size size: sizes) {
+            if (size.width == width && size.height == height) {
+                return true;
+            }
+        }
+        return false;
+    }
 }
diff --git a/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java b/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java
index b9d054f..9c6fb39 100644
--- a/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java
+++ b/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java
@@ -577,6 +577,42 @@
         }.run();
     }
 
+    @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "addJavascriptInterface",
+        args = {Object.class, String.class}
+    )
+    public void testAddJavascriptInterfaceNull() throws Exception {
+        WebSettings settings = mWebView.getSettings();
+        settings.setJavaScriptEnabled(true);
+        String setTitleToPropertyTypeHtml = "<html><head></head>" +
+                "<body onload=\"document.title = typeof window.injectedObject;\"></body></html>";
+
+        // Test that the property is initially undefined.
+        mWebView.loadData(setTitleToPropertyTypeHtml, "text/html", "UTF-8");
+        waitForLoadComplete(mWebView, TEST_TIMEOUT);
+        assertEquals("undefined", mWebView.getTitle());
+
+        // Test that adding a null object has no effect.
+        mWebView.addJavascriptInterface(null, "injectedObject");
+        mWebView.loadData(setTitleToPropertyTypeHtml, "text/html", "UTF-8");
+        waitForLoadComplete(mWebView, TEST_TIMEOUT);
+        assertEquals("undefined", mWebView.getTitle());
+
+        // Test that adding an object gives an object type.
+        final DummyJavaScriptInterface obj = new DummyJavaScriptInterface();
+        mWebView.addJavascriptInterface(obj, "injectedObject");
+        mWebView.loadData(setTitleToPropertyTypeHtml, "text/html", "UTF-8");
+        waitForLoadComplete(mWebView, TEST_TIMEOUT);
+        assertEquals("object", mWebView.getTitle());
+
+        // Test that trying to replace with a null object has no effect.
+        mWebView.addJavascriptInterface(null, "injectedObject");
+        mWebView.loadData(setTitleToPropertyTypeHtml, "text/html", "UTF-8");
+        waitForLoadComplete(mWebView, TEST_TIMEOUT);
+        assertEquals("object", mWebView.getTitle());
+    }
+
     @TestTargets({
         @TestTargetNew(
             level = TestLevel.COMPLETE,