am 24a61773: am 6e87cc11: am a2ab5875: am 9f0a386e: Merge "Salvage Broken ContactsTests" into gingerbread

* commit '24a617736ec9e65960de1fbf7d96c4b8dfb40178':
  Salvage Broken ContactsTests
diff --git a/tests/tests/app/src/android/app/cts/InstrumentationTest.java b/tests/tests/app/src/android/app/cts/InstrumentationTest.java
index 6ab9ac6..d2c55c2 100644
--- a/tests/tests/app/src/android/app/cts/InstrumentationTest.java
+++ b/tests/tests/app/src/android/app/cts/InstrumentationTest.java
@@ -954,6 +954,11 @@
             }
 
             @Override
+            public boolean superDispatchGenericMotionEvent(MotionEvent event) {
+                return false;
+            }
+
+            @Override
             public void takeKeyEvents(boolean get) {
             }
 
diff --git a/tests/tests/database/src/android/database/sqlite/cts/SQLiteDatabaseTest.java b/tests/tests/database/src/android/database/sqlite/cts/SQLiteDatabaseTest.java
index 4d2724a..bb2c831 100644
--- a/tests/tests/database/src/android/database/sqlite/cts/SQLiteDatabaseTest.java
+++ b/tests/tests/database/src/android/database/sqlite/cts/SQLiteDatabaseTest.java
@@ -36,6 +36,8 @@
 import android.test.MoreAsserts;
 import android.test.suitebuilder.annotation.LargeTest;
 import android.test.suitebuilder.annotation.SmallTest;
+import android.test.suitebuilder.annotation.Suppress;
+
 import dalvik.annotation.TestTargets;
 import dalvik.annotation.TestTargetNew;
 import dalvik.annotation.TestLevel;
@@ -1532,6 +1534,7 @@
      *</p>
      * @throws InterruptedException
      */
+    @Suppress
     @LargeTest
     public void testReaderGetsOldVersionOfDataWhenWriterIsInXact() throws InterruptedException {
         // redo setup to create WAL enabled database
@@ -1606,12 +1609,7 @@
         }
     }
 
-    @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            notes = "test exceptions from enableWriteAheadLogging().",
-            method = "enableWriteAheadLogging",
-            args = {}
-        )
+    @Suppress
     public void testExceptionsFromEnableWriteAheadLogging() {
         // attach a database
         // redo setup to create WAL enabled database
diff --git a/tests/tests/drm/Android.mk b/tests/tests/drm/Android.mk
new file mode 100644
index 0000000..c9b5026
--- /dev/null
+++ b/tests/tests/drm/Android.mk
@@ -0,0 +1,35 @@
+# Copyright (C) 2011 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.
+
+LOCAL_PATH:= $(call my-dir)
+
+include $(CLEAR_VARS)
+
+# don't include this package in any target
+LOCAL_MODULE_TAGS := optional
+# and when built explicitly put it in the data partition
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+
+LOCAL_JAVA_LIBRARIES := android.test.runner
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+LOCAL_PACKAGE_NAME := CtsDRMTestCases
+
+LOCAL_INSTRUMENTATION_FOR := CtsTestStubs
+
+# uncomment when dalvik.annotation.Test* are removed or part of SDK
+#LOCAL_SDK_VERSION := current
+
+include $(BUILD_PACKAGE)
diff --git a/tests/tests/drm/AndroidManifest.xml b/tests/tests/drm/AndroidManifest.xml
new file mode 100644
index 0000000..fe515f3
--- /dev/null
+++ b/tests/tests/drm/AndroidManifest.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 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.
+-->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="com.android.cts.drm">
+
+    <application>
+        <uses-library android:name="android.test.runner" />
+    </application>
+
+    <instrumentation android:name="android.test.InstrumentationCtsTestRunner"
+                     android:targetPackage="com.android.cts.stub"
+                     android:label="CTS tests of android.drm"/>
+
+</manifest>
+
diff --git a/tests/tests/drm/README b/tests/tests/drm/README
new file mode 100644
index 0000000..dd0ef17
--- /dev/null
+++ b/tests/tests/drm/README
@@ -0,0 +1,6 @@
+- User of CTS code needs to edit configuration files in
+  "src/android/drm/cts/configs/" according to the specification
+  of user's DRM plug-in.
+- If new plug-in is added, user should add corresponding configuration
+  file under "src/android/drm/cts/configs/" and update
+  "src/android/drm/cts/ConfigFactory.java".
diff --git a/tests/tests/drm/src/android/drm/cts/Config.java b/tests/tests/drm/src/android/drm/cts/Config.java
new file mode 100644
index 0000000..736c0ad
--- /dev/null
+++ b/tests/tests/drm/src/android/drm/cts/Config.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2011 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 android.drm.cts;
+
+import java.util.HashMap;
+
+public interface Config {
+    String getPluginName();
+    String getMimeType();
+    String getAccountId();
+    String getRightsPath();
+    String getContentPath();
+    HashMap<String, String> getInfoOfRegistration();
+    HashMap<String, String> getInfoOfUnregistration();
+    HashMap<String, String> getInfoOfRightsAcquisition();
+}
diff --git a/tests/tests/drm/src/android/drm/cts/ConfigFactory.java b/tests/tests/drm/src/android/drm/cts/ConfigFactory.java
new file mode 100644
index 0000000..339c5b5
--- /dev/null
+++ b/tests/tests/drm/src/android/drm/cts/ConfigFactory.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2011 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 android.drm.cts;
+
+import android.util.Log;
+
+import android.drm.cts.configs.PassthruConfig;
+
+public final class ConfigFactory {
+    private static final String TAG = "ConfigFactory";
+
+    /**
+     * Get configurations of specified plug-in name.
+     *
+     * @param plugInName Name of DRM plug-in. The name SHOULD be consistent with
+     *                   the name defined in plug-in's onGetSupportInfo().
+     */
+    public static Config getConfig(String plugInName) {
+        if (plugInName.equals("Passthru plug-in")) {
+            return PassthruConfig.getInstance();
+        } else {
+            Log.e(TAG, "Configuration for " + plugInName + " is not registered.");
+            return null;
+        }
+    }
+}
diff --git a/tests/tests/drm/src/android/drm/cts/DRMTest.java b/tests/tests/drm/src/android/drm/cts/DRMTest.java
new file mode 100644
index 0000000..39aeb0a
--- /dev/null
+++ b/tests/tests/drm/src/android/drm/cts/DRMTest.java
@@ -0,0 +1,242 @@
+/*
+ * Copyright (C) 2011 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 android.drm.cts;
+
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTargetClass;
+import dalvik.annotation.TestTargetNew;
+
+import android.content.ContentValues;
+import android.test.AndroidTestCase;
+import android.util.Log;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import android.drm.DrmManagerClient;
+import android.drm.DrmConvertedStatus;
+import android.drm.DrmEvent;
+import android.drm.DrmInfo;
+import android.drm.DrmInfoRequest;
+import android.drm.DrmInfoStatus;
+import android.drm.DrmRights;
+import android.drm.DrmStore;
+import android.drm.DrmUtils;
+
+@TestTargetClass(DrmManagerClient.class)
+public class DRMTest extends AndroidTestCase {
+    private static String TAG = "CtsDRMTest";
+    private static final int WAIT_TIME = 60000; // 1 min max
+
+    private Object mLock = new Object();
+    private ArrayList<Config> mConfigs = new ArrayList<Config>();
+    private DrmRights mDrmRights;
+    private DrmManagerClient mDrmManagerClient;
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        mDrmManagerClient = new DrmManagerClient(getContext());
+        String[] plugins = mDrmManagerClient.getAvailableDrmEngines();
+
+        mConfigs.clear();
+        for(String plugInName : plugins) {
+            Config config = ConfigFactory.getConfig(plugInName);
+            if (null != config) {
+                mConfigs.add(config);
+            }
+        }
+    }
+
+    private void register(Config config) throws Exception {
+        DrmInfo drmInfo = executeAcquireDrmInfo(DrmInfoRequest.TYPE_REGISTRATION_INFO,
+                                            config.getInfoOfRegistration(),
+                                            config.getMimeType());
+        executeProcessDrmInfo(drmInfo, config);
+    }
+
+    private void acquireRights(Config config) throws Exception {
+        DrmInfo drmInfo = executeAcquireDrmInfo(DrmInfoRequest.TYPE_RIGHTS_ACQUISITION_INFO,
+                                            config.getInfoOfRightsAcquisition(),
+                                            config.getMimeType());
+        executeProcessDrmInfo(drmInfo, config);
+    }
+
+    private void deregister(Config config) throws Exception {
+        DrmInfo drmInfo = executeAcquireDrmInfo(DrmInfoRequest.TYPE_UNREGISTRATION_INFO,
+                                            config.getInfoOfRegistration(),
+                                            config.getMimeType());
+        executeProcessDrmInfo(drmInfo, config);
+    }
+
+    public void testRegisterAndDeregister() throws Exception {
+        for (Config config : mConfigs) {
+            register(config);
+            deregister(config);
+        }
+    }
+
+    public void testAcquireRights() throws Exception {
+        for (Config config : mConfigs) {
+            register(config);
+            acquireRights(config);
+            deregister(config);
+        }
+    }
+
+    public void testGetConstraints() throws Exception {
+        for (Config config : mConfigs) {
+            register(config);
+            acquireRights(config);
+            ContentValues constraints = mDrmManagerClient.getConstraints(
+                                            config.getContentPath(),
+                                            DrmStore.Action.DEFAULT);
+            assertNotNull("Failed on plugin: " + config.getPluginName(), constraints);
+            deregister(config);
+        }
+    }
+
+    public void testCanHandle() throws Exception {
+        for (Config config : mConfigs) {
+            assertTrue("Failed on plugin: " + config.getPluginName(),
+                    mDrmManagerClient.canHandle(config.getContentPath(), config.getMimeType()));
+        }
+    }
+
+    public void testGetOriginalMimeType() throws Exception {
+        for (Config config : mConfigs) {
+            assertNotNull("Failed on plugin: " + config.getPluginName(),
+                    mDrmManagerClient.getOriginalMimeType(config.getContentPath()));
+        }
+    }
+
+    public void testCheckRightsStatus() throws Exception {
+        for (Config config : mConfigs) {
+            register(config);
+            acquireRights(config);
+            int rightsStatus = mDrmManagerClient.checkRightsStatus(
+                                                config.getContentPath(),
+                                                DrmStore.Action.PLAY);
+            assertEquals("Failed on plugin: " + config.getPluginName(),
+                    DrmStore.RightsStatus.RIGHTS_VALID, rightsStatus);
+            deregister(config);
+        }
+    }
+
+    public void testRemoveRights() throws Exception {
+        for (Config config : mConfigs) {
+            assertEquals("Failed on plugin: " + config.getPluginName(),
+                    DrmManagerClient.ERROR_NONE,
+                    mDrmManagerClient.removeRights(config.getContentPath()));
+        }
+    }
+
+    public void testRemoveAllRights() throws Exception {
+        for (Config config : mConfigs) {
+            assertEquals("Failed on plugin: " + config.getPluginName(),
+                    mDrmManagerClient.removeAllRights(), DrmManagerClient.ERROR_NONE);
+        }
+    }
+
+    public void testConvertData() throws Exception {
+        for (Config config : mConfigs) {
+            byte[] inputData = new byte[]{'T','E','S','T'};
+
+            int convertId = mDrmManagerClient.openConvertSession(config.getMimeType());
+            DrmConvertedStatus drmConvertStatus
+                                = mDrmManagerClient.convertData(convertId, inputData);
+            mDrmManagerClient.closeConvertSession(convertId);
+        }
+    }
+
+    private DrmInfo executeAcquireDrmInfo(
+            int type, HashMap<String, String> request, String mimeType) throws Exception {
+        DrmInfoRequest infoRequest = new DrmInfoRequest(type, mimeType);
+
+        for (Iterator it = request.keySet().iterator(); it.hasNext(); ) {
+            String key = (String) it.next();
+            String value = request.get(key);
+            infoRequest.put(key, value);
+        }
+
+        return mDrmManagerClient.acquireDrmInfo(infoRequest);
+    }
+
+    private void executeProcessDrmInfo(DrmInfo drmInfo, Config config) throws Exception {
+        assertNotNull("Failed on plugin: " + config.getPluginName(), drmInfo);
+
+        mDrmManagerClient.setOnEventListener(new OnEventListenerImpl(config));
+        drmInfo.put(DrmInfoRequest.ACCOUNT_ID, config.getAccountId());
+        assertEquals("Failed on plugin: " + config.getPluginName(),
+                DrmManagerClient.ERROR_NONE, mDrmManagerClient.processDrmInfo(drmInfo));
+
+        synchronized(mLock) {
+            try {
+                mLock.wait(WAIT_TIME);
+            } catch(Exception e) {
+                Log.v(TAG, "ProcessDrmInfo: wait was interrupted.");
+            }
+        }
+    }
+
+    private class OnEventListenerImpl implements DrmManagerClient.OnEventListener {
+        private Config mConfig;
+        public OnEventListenerImpl(Config config) {
+            mConfig = config;
+        }
+
+        @Override
+        public void onEvent(DrmManagerClient client, DrmEvent event,
+                    HashMap<String, Object> attributes) {
+            switch (event.getType()) {
+            case DrmEvent.TYPE_DRM_INFO_PROCESSED:
+                Log.d(TAG, "processDrmInfo() completed");
+                DrmInfoStatus infoStatus
+                        = (DrmInfoStatus) attributes.get(DrmEvent.DRM_INFO_STATUS_OBJECT);
+                switch (infoStatus.infoType) {
+                case DrmInfoRequest.TYPE_RIGHTS_ACQUISITION_INFO:
+                    mDrmRights = new DrmRights(infoStatus.data, infoStatus.mimeType);
+                    assertNotNull(mDrmRights);
+                    try {
+                        assertEquals(DrmManagerClient.ERROR_NONE, mDrmManagerClient.saveRights(
+                                    mDrmRights, mConfig.getRightsPath(), mConfig.getContentPath()));
+                        Log.d(TAG, "Rights saved");
+                    } catch (IOException e) {
+                        Log.e(TAG, "Save Rights failed");
+                        e.printStackTrace();
+                    }
+                    break;
+                case DrmInfoRequest.TYPE_REGISTRATION_INFO:
+                    Log.d(TAG, "Registration completed");
+                    break;
+                case DrmInfoRequest.TYPE_UNREGISTRATION_INFO:
+                    Log.d(TAG, "Deregistration completed");
+                    break;
+                default:
+                    break;
+                }
+                break;
+            default:
+                break;
+            }
+            synchronized (mLock) {
+                mLock.notify();
+            }
+        }
+    }
+}
diff --git a/tests/tests/drm/src/android/drm/cts/configs/PassthruConfig.java b/tests/tests/drm/src/android/drm/cts/configs/PassthruConfig.java
new file mode 100644
index 0000000..7310825
--- /dev/null
+++ b/tests/tests/drm/src/android/drm/cts/configs/PassthruConfig.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2011 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 android.drm.cts.configs;
+
+import java.util.HashMap;
+
+import android.drm.cts.Config;
+
+public class PassthruConfig implements Config {
+    private static PassthruConfig sInstance = new PassthruConfig();
+    private PassthruConfig() {}
+    public static PassthruConfig getInstance() {
+        return sInstance;
+    }
+    public String getPluginName() {
+        return "Passthru";
+    }
+    public String getMimeType() {
+        return "application/vnd.passthru.drm";
+    }
+    public String getAccountId() {
+        return "01234567";
+    }
+    public String getRightsPath() {
+        return "/sdcard/dummy_passthru_rights.xml";
+    }
+    public String getContentPath() {
+        return "/sdcard/dummy_passthru_content.passthru";
+    }
+    public HashMap<String, String> getInfoOfRegistration() {
+        return sInfoOfRegistration;
+    }
+    public HashMap<String, String> getInfoOfUnregistration() {
+        return sInfoOfUnregistration;
+    }
+    public HashMap<String, String> getInfoOfRightsAcquisition(){
+        return sInfoOfRightsAcquisition;
+    }
+
+    private static HashMap<String, String> sInfoOfRegistration = new HashMap<String, String>();
+    private static HashMap<String, String> sInfoOfUnregistration = new HashMap<String, String>();
+    private static HashMap<String, String> sInfoOfRightsAcquisition = new HashMap<String, String>();
+
+    static {
+        sInfoOfRegistration.put("Foo-1", "foo-1");
+
+        sInfoOfUnregistration.put("Foo-2", "foo-2");
+
+        sInfoOfRightsAcquisition.put("Foo-3", "foo-3");
+    }
+}
diff --git a/tests/tests/provider/src/android/provider/cts/BrowserTest.java b/tests/tests/provider/src/android/provider/cts/BrowserTest.java
index 9eb5b82..b4be450 100644
--- a/tests/tests/provider/src/android/provider/cts/BrowserTest.java
+++ b/tests/tests/provider/src/android/provider/cts/BrowserTest.java
@@ -80,6 +80,11 @@
                 ContentValues value = new ContentValues();
 
                 for (int i = 0; i < colNames.length; i++) {
+                    if (Bookmarks.PARENT_SOURCE_ID.equals(colNames[i])
+                            || Bookmarks.INSERT_AFTER_SOURCE_ID.equals(colNames[i])) {
+                        // These aren't actual columns, so skip them in the backup
+                        continue;
+                    }
                     switch (cursor.getType(i)) {
                     case Cursor.FIELD_TYPE_BLOB:
                         value.put(colNames[i], cursor.getBlob(i));
diff --git a/tests/tests/text/src/android/text/format/cts/DateFormatTest.java b/tests/tests/text/src/android/text/format/cts/DateFormatTest.java
index 37b337f..f24117e 100644
--- a/tests/tests/text/src/android/text/format/cts/DateFormatTest.java
+++ b/tests/tests/text/src/android/text/format/cts/DateFormatTest.java
@@ -32,6 +32,7 @@
 import java.util.Date;
 import java.util.GregorianCalendar;
 import java.util.Locale;
+import java.util.TimeZone;
 
 @TestTargetClass(DateFormat.class)
 public class DateFormatTest extends AndroidTestCase {
@@ -174,4 +175,29 @@
         actual = DateFormat.format(format, formatDate.getTime());
         assertEquals(expectedString, actual.toString());
     }
+
+    @TestTargetNew(level = TestLevel.ADDITIONAL)
+    public void test2038() {
+        Calendar calendar = new GregorianCalendar(TimeZone.getTimeZone("UTC"));
+
+        calendar.setTimeInMillis(((long) Integer.MIN_VALUE + Integer.MIN_VALUE) * 1000L);
+        assertEquals("Sun Nov 24 17:31:44 GMT+00:00 1833",
+                DateFormat.format("EEE MMM dd kk:mm:ss zzz yyyy", calendar));
+
+        calendar.setTimeInMillis(Integer.MIN_VALUE * 1000L);
+        assertEquals("Fri Dec 13 20:45:52 GMT+00:00 1901",
+                DateFormat.format("EEE MMM dd kk:mm:ss zzz yyyy", calendar));
+
+        calendar.setTimeInMillis(0L);
+        assertEquals("Thu Jan 01 00:00:00 GMT+00:00 1970",
+                DateFormat.format("EEE MMM dd kk:mm:ss zzz yyyy", calendar));
+
+        calendar.setTimeInMillis(Integer.MAX_VALUE * 1000L);
+        assertEquals("Tue Jan 19 03:14:07 GMT+00:00 2038",
+                DateFormat.format("EEE MMM dd kk:mm:ss zzz yyyy", calendar));
+
+        calendar.setTimeInMillis((2L + Integer.MAX_VALUE + Integer.MAX_VALUE) * 1000L);
+        assertEquals("Sun Feb 07 06:28:16 GMT+00:00 2106",
+                DateFormat.format("EEE MMM dd kk:mm:ss zzz yyyy", calendar));
+    }
 }
diff --git a/tests/tests/text/src/android/text/format/cts/DateUtilsTest.java b/tests/tests/text/src/android/text/format/cts/DateUtilsTest.java
index a5dd335..cbc35a5 100644
--- a/tests/tests/text/src/android/text/format/cts/DateUtilsTest.java
+++ b/tests/tests/text/src/android/text/format/cts/DateUtilsTest.java
@@ -16,17 +16,17 @@
 
 package android.text.format.cts;
 
+import android.content.Context;
+import android.test.AndroidTestCase;
+import android.text.format.DateUtils;
+import dalvik.annotation.KnownFailure;
 import dalvik.annotation.TestLevel;
 import dalvik.annotation.TestTargetClass;
 import dalvik.annotation.TestTargetNew;
 import dalvik.annotation.TestTargets;
-
-import android.content.Context;
-import android.test.AndroidTestCase;
-import android.text.format.DateUtils;
-
 import java.util.Calendar;
 import java.util.Date;
+import java.util.Formatter;
 import java.util.Locale;
 
 @TestTargetClass(DateUtils.class)
@@ -303,4 +303,32 @@
         assertTrue(DateUtils.isToday(mBaseTime));
         assertFalse(DateUtils.isToday(mBaseTime - DAY_DURATION));
     }
+
+    /**
+     * DateUtils is broken beyond Integer.MAX_VALUE seconds of 1970.
+     * http://code.google.com/p/android/issues/detail?id=13050
+     */
+    @TestTargetNew(level = TestLevel.ADDITIONAL)
+    @KnownFailure("http://b/2519073")
+    public void test2038() {
+        assertEquals("00:00, Thursday, January 1, 1970", formatFull(0L));
+
+        // these tests all fail in Honeycomb
+        assertEquals("17:31, Sunday, November 24, 1833",
+                formatFull(((long) Integer.MIN_VALUE + Integer.MIN_VALUE) * 1000L));
+        assertEquals("20:45, Friday, December 13, 1901", formatFull(Integer.MIN_VALUE * 1000L));
+        assertEquals("03:14, Tuesday, January 19, 2038", formatFull(Integer.MAX_VALUE * 1000L));
+        assertEquals("06:28, Sunday, February 7, 2106",
+                formatFull((2L + Integer.MAX_VALUE + Integer.MAX_VALUE) * 1000L));
+    }
+
+    private String formatFull(long millis) {
+        Formatter formatter = new Formatter();
+        int flags = DateUtils.FORMAT_SHOW_DATE
+                | DateUtils.FORMAT_SHOW_WEEKDAY
+                | DateUtils.FORMAT_SHOW_TIME
+                | DateUtils.FORMAT_24HOUR;
+        DateUtils.formatDateRange(null, formatter, millis, millis, flags, "UTC");
+        return formatter.toString();
+    }
 }
diff --git a/tests/tests/view/src/android/view/cts/WindowTest.java b/tests/tests/view/src/android/view/cts/WindowTest.java
index f7cdbac..4b9e282 100644
--- a/tests/tests/view/src/android/view/cts/WindowTest.java
+++ b/tests/tests/view/src/android/view/cts/WindowTest.java
@@ -1122,6 +1122,10 @@
             return true;
         }
 
+        public boolean superDispatchGenericMotionEvent(MotionEvent event) {
+            return true;
+        }
+
         public View getDecorView() {
             return null;
         }
@@ -1200,6 +1204,10 @@
             return true;
         }
 
+        public boolean dispatchGenericMotionEvent(MotionEvent event) {
+            return true;
+        }
+
         public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
             return true;
         }
diff --git a/tests/tests/webkit/src/android/webkit/cts/WebSettingsTest.java b/tests/tests/webkit/src/android/webkit/cts/WebSettingsTest.java
index 9f4f8d0..c28e162 100644
--- a/tests/tests/webkit/src/android/webkit/cts/WebSettingsTest.java
+++ b/tests/tests/webkit/src/android/webkit/cts/WebSettingsTest.java
@@ -244,7 +244,6 @@
             args = {boolean.class}
         )
     })
-    @ToBeFixed(explanation = "Implementation does not work as expected.")
     public void testAccessBlockNetworkImage() throws Exception {
         String url = TestHtmlConstants.EMBEDDED_IMG_URL;
         final String ext = MimeTypeMap.getFileExtensionFromUrl(url);
@@ -260,13 +259,11 @@
             }
         }.run();
 
-        /* ToBeFixed: Uncomment after fixing the framework
         mWebView.clearCache(true);
         mSettings.setBlockNetworkImage(true);
         assertTrue(mSettings.getBlockNetworkImage());
-        loadUrl(url);
+        loadAssetUrl(url);
         assertTrue(mWebServer.getLastRequestUrl().endsWith(ext));
-        */
     }
 
     @TestTargets({
diff --git a/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java b/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java
index 6f62cb9..c831f12 100644
--- a/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java
+++ b/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java
@@ -38,6 +38,7 @@
 import android.os.Handler;
 import android.os.Looper;
 import android.os.Message;
+import android.os.SystemClock;
 import android.test.ActivityInstrumentationTestCase2;
 import android.test.UiThreadTest;
 import android.util.AttributeSet;
@@ -1397,8 +1398,9 @@
         handler.reset();
         int[] location = new int[2];
         mWebView.getLocationOnScreen(location);
+        long time = SystemClock.uptimeMillis();
         getInstrumentation().sendPointerSync(
-                MotionEvent.obtain(0, 0, MotionEvent.ACTION_DOWN,
+                MotionEvent.obtain(time, time, MotionEvent.ACTION_DOWN,
                         location[0] + imgWidth / 2,
                         location[1] + imgHeight / 2, 0));
         mWebView.requestImageRef(msg);