am a154856e: Merge "Fix MediaStore_Video_MediaTest Again" into honeycomb
* commit 'a154856e0bc5ddeb8070737bb2f7464bbb79d3f0':
Fix MediaStore_Video_MediaTest Again
diff --git a/tests/tests/app/src/android/app/cts/AlarmManagerTest.java b/tests/tests/app/src/android/app/cts/AlarmManagerTest.java
index dc2ff92..7c03a75 100644
--- a/tests/tests/app/src/android/app/cts/AlarmManagerTest.java
+++ b/tests/tests/app/src/android/app/cts/AlarmManagerTest.java
@@ -16,28 +16,19 @@
package android.app.cts;
-import java.util.TimeZone;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTargetClass;
+import dalvik.annotation.TestTargetNew;
+import dalvik.annotation.ToBeFixed;
import android.app.AlarmManager;
import android.app.PendingIntent;
-import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
-import android.content.ServiceConnection;
-import android.os.IBinder;
import android.os.SystemClock;
-import android.app.cts.ISecondary;
import android.test.AndroidTestCase;
-import dalvik.annotation.BrokenTest;
-import dalvik.annotation.TestTargets;
-import dalvik.annotation.TestStatus;
-import dalvik.annotation.TestTargetNew;
-import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTargetClass;
-import dalvik.annotation.ToBeFixed;
-
@TestTargetClass(AlarmManager.class)
public class AlarmManagerTest extends AndroidTestCase {
private AlarmManager mAlarmManager;
@@ -52,11 +43,8 @@
private long mWakeupTime;
private MockAlarmReceiver mMockAlarmReceiver;
- private Sync mSync;
-
private final int TIME_DELTA = 200;
private final int TIME_DELAY = 2000;
- private ISecondary mSecondaryService = null;
class Sync {
public boolean mIsConnected;
@@ -83,79 +71,6 @@
}
@TestTargetNew(
- level = TestLevel.COMPLETE,
- method = "setTimeZone",
- args = {java.lang.String.class}
- )
- @BrokenTest("Broken by CL148448. Default timezone of the test and the service differ.")
- public void testSetTimeZone() throws Exception {
- mSync = new Sync();
- final String ACTION = "android.app.REMOTESERVICE";
- mServiceIntent = new Intent(ACTION);
- mContext.startService(mServiceIntent);
- mContext.bindService(new Intent(ISecondary.class.getName()), mSecondaryConnection,
- Context.BIND_AUTO_CREATE);
-
- synchronized (mSync) {
- if (!mSync.mIsConnected) {
- mSync.wait();
- }
- }
- final TimeZone currentZone = TimeZone.getDefault();
-
- // test timeZone is null, timeZone won't be set
- String timeZone = null;
- mAlarmManager.setTimeZone(timeZone);
- TimeZone values = TimeZone.getDefault();
- assertEquals(currentZone.getID(), values.getID());
- // test another process's timezone
-
- assertEquals(currentZone.getID(), mSecondaryService.getTimeZoneID());
-
- // nothing in timZone, timeZone won't be set
- timeZone = "";
- mAlarmManager.setTimeZone(timeZone);
- values = TimeZone.getDefault();
- assertEquals(currentZone.getID(), values.getID());
- // test timeZone as different time zone
- String[] timeZones = TimeZone.getAvailableIDs();
- // set different time zone
- timeZone = currentZone.getID().equals(timeZones[0]) ? timeZones[1] : timeZones[0];
- mAlarmManager.setTimeZone(timeZone);
- Thread.sleep(TIME_DELAY);
- values = TimeZone.getDefault();
- TimeZone zone = TimeZone.getTimeZone(timeZone);
- assertEquals(zone.getID(), values.getID());
-
- // test another process's timezone
- assertEquals(zone.getID(), mSecondaryService.getTimeZoneID());
-
- // set time zone as origin time zone
- TimeZone.setDefault(currentZone);
-
- mContext.stopService(mServiceIntent);
- mServiceIntent = null;
- }
-
- private ServiceConnection mSecondaryConnection = new ServiceConnection() {
- public void onServiceConnected(ComponentName className, IBinder service) {
- mSecondaryService = ISecondary.Stub.asInterface(service);
- synchronized (mSync) {
- mSync.mIsConnected = true;
- mSync.notify();
- }
- }
-
- public void onServiceDisconnected(ComponentName className) {
- mSecondaryService = null;
- synchronized (mSync) {
- mSync.mIsDisConnected = true;
- mSync.notify();
- }
- }
- };
-
- @TestTargetNew(
level = TestLevel.PARTIAL,
method = "set",
args = {int.class, long.class, android.app.PendingIntent.class}
@@ -216,7 +131,7 @@
Thread.sleep(TIME_DELAY);
assertTrue(mMockAlarmReceiver.alarmed);
}
-
+
@TestTargetNew(
level = TestLevel.PARTIAL,
method = "setRepeating",
diff --git a/tests/tests/content/src/android/content/cts/ContextWrapperTest.java b/tests/tests/content/src/android/content/cts/ContextWrapperTest.java
index ac402ef..65bdc47 100644
--- a/tests/tests/content/src/android/content/cts/ContextWrapperTest.java
+++ b/tests/tests/content/src/android/content/cts/ContextWrapperTest.java
@@ -18,7 +18,6 @@
import com.android.cts.stub.R;
-import dalvik.annotation.BrokenTest;
import dalvik.annotation.TestLevel;
import dalvik.annotation.TestTargetClass;
import dalvik.annotation.TestTargetNew;
@@ -247,7 +246,6 @@
args = {int.class}
)
})
- @BrokenTest("needs investigation")
public void testAccessTheme() {
mContextWrapper.setTheme(R.style.Test_Theme);
final Theme testTheme = mContextWrapper.getTheme();
@@ -258,11 +256,18 @@
android.R.attr.panelColorForeground,
android.R.attr.panelColorBackground
};
- TypedArray attrArray = testTheme.obtainStyledAttributes(attrs);
-
- assertTrue(attrArray.getBoolean(0, false));
- assertEquals(0xff000000, attrArray.getColor(1, 0));
- assertEquals(0xffffffff, attrArray.getColor(2, 0));
+ TypedArray attrArray = null;
+ try {
+ attrArray = testTheme.obtainStyledAttributes(attrs);
+ assertTrue(attrArray.getBoolean(0, false));
+ assertEquals(0xff000000, attrArray.getColor(1, 0));
+ assertEquals(0xffffffff, attrArray.getColor(2, 0));
+ } finally {
+ if (attrArray != null) {
+ attrArray.recycle();
+ attrArray = null;
+ }
+ }
// setTheme only works for the first time
mContextWrapper.setTheme(android.R.style.Theme_Black);
diff --git a/tests/tests/dpi/src/android/dpi/cts/ConfigurationTest.java b/tests/tests/dpi/src/android/dpi/cts/ConfigurationTest.java
index f038c4b..cb420a6 100644
--- a/tests/tests/dpi/src/android/dpi/cts/ConfigurationTest.java
+++ b/tests/tests/dpi/src/android/dpi/cts/ConfigurationTest.java
@@ -17,235 +17,35 @@
package android.dpi.cts;
import android.content.Context;
-import android.content.res.Configuration;
import android.test.AndroidTestCase;
+import android.util.DisplayMetrics;
import android.view.Display;
import android.view.WindowManager;
-import android.util.DisplayMetrics;
-
-import java.lang.Integer;
-import java.util.EnumSet;
/**
- * This is verifying that the device under test is running a supported
- * resolution, and is being classified as the right Screen Layout
- * Size.
+ * Test for verifying a device's screen configuration.
*/
public class ConfigurationTest extends AndroidTestCase {
- private enum Density {
- // It is important to keep these sorted
- INVALID_LOW(Integer.MIN_VALUE, 99),
- LOW (100, 140),
- MEDIUM (141, 190),
- HIGH (191, 250),
- INVALID_HIGH(251, Integer.MAX_VALUE);
+ public void testScreenConfiguration() {
+ WindowManager windowManager =
+ (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE);
+ Display display = windowManager.getDefaultDisplay();
+ DisplayMetrics metrics = new DisplayMetrics();
+ display.getMetrics(metrics);
- private int low;
- private int high;
+ double xInches = (double) metrics.widthPixels / metrics.xdpi;
+ double yInches = (double) metrics.heightPixels / metrics.ydpi;
+ double diagonalInches = Math.sqrt(Math.pow(xInches, 2) + Math.pow(yInches, 2));
+ assertTrue("Screen diagonal must be at least 2.5 inches: " + diagonalInches,
+ diagonalInches >= 2.5d);
- Density(int low, int high) {
- this.low = low;
- this.high = high;
- }
+ double density = 160.0d * metrics.density;
+ assertTrue("Screen density must be at least 100 dpi: " + density, density >= 100.0d);
- public static Density findDensity(int value) {
- Density density = INVALID_LOW;
- for (Density d : EnumSet.range(Density.INVALID_LOW, Density.INVALID_HIGH)) {
- if (value >= d.low && value <= d.high) {
- density = d;
- break;
- }
- }
- return density;
- }
- };
-
- /**
- * Holds information on the current active screen's configuration.
- */
- private static class ActiveScreenConfiguration {
- private final int width;
- private final int height;
- private final Density density;
-
- /**
- * Create a new ActiveScreenConfiguration.
- *
- * @param width the width of the screen
- * @param height the height of the screen
- * @param density the scaling factor for DIP from standard
- * density (160.0)
- */
- public ActiveScreenConfiguration(int width,
- int height,
- float density) {
- // 160 DIP is the "standard" density
- this(width, height, Density.findDensity((int) (160.0f * density)));
- }
-
- protected ActiveScreenConfiguration(int width,
- int height,
- Density density) {
- this.width = width;
- this.height = height;
- this.density = density;
- }
-
- public Density getDensity() {
- return density;
- }
-
- public int getWidth() {
- return width;
- }
-
- public int getHeight() {
- return height;
- }
- }
-
- private static class ScreenConfiguration extends ActiveScreenConfiguration {
- private final int screenLayout;
- private final boolean isWide;
-
- public ScreenConfiguration(int width,
- int height,
- Density density,
- int screenLayout,
- boolean isWide) {
- super(width, height, density);
- this.screenLayout = screenLayout;
- this.isWide = isWide;
- }
-
- public ScreenConfiguration(int width,
- int height,
- Density density,
- int screenLayout) {
- this(width, height, density, screenLayout, false);
- }
-
- public int getScreenLayout() {
- return screenLayout;
- }
-
- public boolean isWide() {
- return isWide;
- }
- };
-
- private static boolean areConfigsEqual(ActiveScreenConfiguration active,
- ScreenConfiguration screenConfig) {
- if (screenConfig.isWide()) {
- // For widescreen configs, the height is fixed but the
- // width only specifies a minimum. But since the device
- // can be both landscape and portrait, we have to search
- // for which way it is.
- if (active.getHeight() == screenConfig.getHeight()) {
- // active height matches config height. Make sure
- // that the active width is at least the config width.
- return active.getWidth() >= screenConfig.getWidth();
- } else if (active.getWidth() == screenConfig.getHeight()) {
- // directions are swapped
- return active.getHeight() >= screenConfig.getWidth();
- } else {
- return false;
- }
- } else {
- if (active.getWidth() == screenConfig.getWidth() &&
- active.getHeight() == screenConfig.getHeight() &&
- active.getDensity().equals(screenConfig.getDensity())) {
- return true;
- }
- // It is also possible that the device is in landscape
- // mode, which flips the active w/h.
- if (active.getHeight() == screenConfig.getWidth() &&
- active.getWidth() == screenConfig.getHeight() &&
- active.getDensity().equals(screenConfig.getDensity())) {
- return true;
- }
- // nope.
- return false;
- }
- }
-
- /**
- * Here's the current configuration table:
- *
- * Resoluion | Density | Size
- * QVGA | low (100-140) | small
- * WQVGA | low (100-140) | normal
- * HVGA | medium (141-190) | normal
- * WVGA | high (191-250) | normal
- * FWVGA | high (191-250) | normal
- * WSVGA | high (191-250) | large
-
- * VGA | medium (141-190) | large
- * WVGA | medium (141-190) | large
- * FWVGA | medium (141-190) | large
- *
- * Any changes to allow additional resolutions will need to update this table
- */
-
- private static final ScreenConfiguration[] SUPPORTED_SCREEN_CONFIGS = {
- // QVGA | low (100-140) | small
- new ScreenConfiguration(240, 320, Density.LOW, Configuration.SCREENLAYOUT_SIZE_SMALL),
- // WQVGA | low (100-140) | normal
- new ScreenConfiguration(240, 320, Density.LOW, Configuration.SCREENLAYOUT_SIZE_SMALL, true),
- // HVGA | medium (141-190) | normal
- new ScreenConfiguration(480, 320, Density.MEDIUM, Configuration.SCREENLAYOUT_SIZE_NORMAL),
- new ScreenConfiguration(640, 240, Density.MEDIUM, Configuration.SCREENLAYOUT_SIZE_NORMAL),
- // WVGA | high (191-250) | normal
- new ScreenConfiguration(640, 480, Density.HIGH, Configuration.SCREENLAYOUT_SIZE_NORMAL, true),
- // FWVGA | high (191-250) | normal
- new ScreenConfiguration(864, 480, Density.HIGH, Configuration.SCREENLAYOUT_SIZE_NORMAL),
- // WSVGA | high (191-250) | large
- new ScreenConfiguration(1024, 600, Density.HIGH, Configuration.SCREENLAYOUT_SIZE_LARGE),
-
- // VGA | medium (141-190) | large
- new ScreenConfiguration(640, 480, Density.MEDIUM, Configuration.SCREENLAYOUT_SIZE_LARGE),
- // WVGA | medium (141-190) | large
- new ScreenConfiguration(640, 480, Density.MEDIUM, Configuration.SCREENLAYOUT_SIZE_LARGE, true),
- // FWVGA | medium (141-190) | large
- new ScreenConfiguration(864, 480, Density.MEDIUM, Configuration.SCREENLAYOUT_SIZE_LARGE),
-
- };
-
- private ActiveScreenConfiguration getCurrentScreenConfig() {
- WindowManager wm = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE);
- Display display = wm.getDefaultDisplay();
- DisplayMetrics dm = new DisplayMetrics();
- display.getMetrics(dm);
- return new ActiveScreenConfiguration(display.getWidth(),
- display.getHeight(),
- dm.density);
- }
-
- /**
- * Get the current screen configuration, make sure it is a
- * supported screen configuration and that the screenlayout size
- * is being set correctly according to the compatibility
- * definition.
- */
- public void testScreenLayoutSize() {
- ActiveScreenConfiguration currentScreenConfig = getCurrentScreenConfig();
- // Make sure we have a valid density for the current screent.
- assertFalse(Density.INVALID_LOW.equals(currentScreenConfig.getDensity()));
- assertFalse(Density.INVALID_HIGH.equals(currentScreenConfig.getDensity()));
-
- // Look up the ScreenConfig in the supported table and make
- // sure we find a match.
- for (ScreenConfiguration screenConfig: SUPPORTED_SCREEN_CONFIGS) {
- if (areConfigsEqual(currentScreenConfig, screenConfig)) {
- Configuration config = getContext().getResources().getConfiguration();
- int size = config.screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK;
- if (screenConfig.getScreenLayout() == size) {
- // we have a match, this is a supported device.
- return;
- }
- }
- }
- fail("Current screen configuration is not supported.");
+ double aspectRatio = (double) Math.max(metrics.widthPixels, metrics.heightPixels)
+ / (double) Math.min(metrics.widthPixels, metrics.heightPixels);
+ assertTrue("Aspect ratio must be between 1.333 (4:3) and 1.779 (16:9): " + aspectRatio,
+ aspectRatio >= 1.333d && aspectRatio <= 1.779d);
}
}
diff --git a/tests/tests/media/src/android/media/cts/MediaRecorderTest.java b/tests/tests/media/src/android/media/cts/MediaRecorderTest.java
index db9c5be..a9e1c33 100644
--- a/tests/tests/media/src/android/media/cts/MediaRecorderTest.java
+++ b/tests/tests/media/src/android/media/cts/MediaRecorderTest.java
@@ -15,7 +15,6 @@
*/
package android.media.cts;
-import dalvik.annotation.BrokenTest;
import dalvik.annotation.TestLevel;
import dalvik.annotation.TestTargetClass;
import dalvik.annotation.TestTargetNew;
@@ -27,6 +26,7 @@
import android.media.MediaRecorder.OnInfoListener;
import android.os.Environment;
import android.test.ActivityInstrumentationTestCase2;
+import android.test.UiThreadTest;
import android.view.Surface;
import java.io.File;
@@ -89,6 +89,7 @@
}
if (mCamera != null) {
mCamera.release();
+ mCamera = null;
}
super.tearDown();
}
@@ -159,10 +160,10 @@
method = "setCamera",
args = {Camera.class}
)
- @BrokenTest(value="No longer works in Donut. CameraService reports: " +
- "Attempt to use locked camera from different process")
+ @UiThreadTest
public void testSetCamera() throws Exception {
mCamera = Camera.open();
+ mCamera.unlock();
mMediaRecorder.setCamera(mCamera);
mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.DEFAULT);
diff --git a/tests/tests/os/src/android/os/cts/MessageQueueTest.java b/tests/tests/os/src/android/os/cts/MessageQueueTest.java
index 95441ae..c7b549a 100644
--- a/tests/tests/os/src/android/os/cts/MessageQueueTest.java
+++ b/tests/tests/os/src/android/os/cts/MessageQueueTest.java
@@ -16,10 +16,7 @@
package android.os.cts;
-import dalvik.annotation.BrokenTest;
-import dalvik.annotation.TestLevel;
import dalvik.annotation.TestTargetClass;
-import dalvik.annotation.TestTargetNew;
import android.os.Handler;
import android.os.HandlerThread;
@@ -30,77 +27,92 @@
import android.os.MessageQueue.IdleHandler;
import android.test.AndroidTestCase;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
@TestTargetClass(MessageQueue.class)
public class MessageQueueTest extends AndroidTestCase {
- private boolean mResult;
- // Action flag: true means addIdleHanlder, false means removeIdleHanlder
- private boolean mActionFlag;
private static final long TIMEOUT = 1000;
- private static final long INTERVAL = 50;
- private IdleHandler mIdleHandler = new IdleHandler() {
- public boolean queueIdle() {
- MessageQueueTest.this.mResult = true;
- return true;
- }
- };
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- mResult = false;
- }
+ public void testAddIdleHandler() throws InterruptedException {
+ TestLooperThread looperThread = new TestLooperThread(Test.ADD_IDLE_HANDLER);
+ looperThread.start();
- /**
- * After calling addIdleHandler (called by MessageQueueTestHelper#doTest), the size of
- * idleHanlder list is not 0 (before calling addIdleHandler, there is no idleHanlder in
- * the test looper we started, that means no idleHanlder with flag mResult), and in doTest,
- * we start a looper, which will queueIdle (Looper.loop()) if idleHanlder list has element,
- * then mResult will be set true. It can make sure addIdleHandler works. If no idleHanlder
- * with flag mResult, mResult will be false.
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- method = "addIdleHandler",
- args = {android.os.MessageQueue.IdleHandler.class}
- )
- @BrokenTest("needs investigation")
- public void testAddIdleHandler() throws RuntimeException, InterruptedException {
try {
- Looper.myQueue().addIdleHandler(null);
- fail("Should throw NullPointerException");
- } catch (NullPointerException e) {
- // expected
+ if (!looperThread.hasIdleHandlerBeenCalled()) {
+ fail("IdleHandler#queueIdle was NOT called: " + looperThread.getTestProgress());
+ }
+ } finally {
+ assertTrue("The looper should have been running.", looperThread.quit());
}
- // If mActionFlag is true, doTest will call addIdleHandler
- mActionFlag = true;
- mResult = false;
- MessageQueueTestHelper tester = new MessageQueueTestHelper();
- tester.doTest(TIMEOUT, INTERVAL);
-
- tester.quit();
- assertTrue(mResult);
}
- /**
- * In this test method, at the beginning of the LooperThread, we call addIdleHandler then
- * removeIdleHandler, there should be no element in idleHanlder list. So the Looper.loop()
- * will not call queueIdle(), mResult will not be set true.
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- method = "removeIdleHandler",
- args = {android.os.MessageQueue.IdleHandler.class}
- )
- @BrokenTest("needs investigation")
- public void testRemoveIdleHandler() throws RuntimeException, InterruptedException {
- mActionFlag = false;
- mResult = false;
- MessageQueueTestHelper tester = new MessageQueueTestHelper();
- tester.doTest(TIMEOUT, INTERVAL);
+ public void testRemoveIdleHandler() throws InterruptedException {
+ TestLooperThread looperThread = new TestLooperThread(Test.REMOVE_IDLE_HANDLER);
+ looperThread.start();
- tester.quit();
- assertFalse(mResult);
+ try {
+ if (looperThread.hasIdleHandlerBeenCalled()) {
+ fail("IdleHandler#queueIdle was called: " + looperThread.getTestProgress());
+ }
+ } finally {
+ assertTrue("The looper should have been running.", looperThread.quit());
+ }
+ }
+
+ private enum Test {ADD_IDLE_HANDLER, REMOVE_IDLE_HANDLER};
+
+ /**
+ * {@link HandlerThread} that adds or removes an idle handler depending on the {@link Test}
+ * given. It uses a {@link CountDownLatch} with an initial count of 2. The first count down
+ * occurs right before the looper's run thread had started running. The final count down
+ * occurs when the idle handler was executed. Tests can call {@link #hasIdleHandlerBeenCalled()}
+ * to see if the countdown reached to 0 or not.
+ */
+ private static class TestLooperThread extends HandlerThread {
+
+ private final Test mTestMode;
+
+ private final CountDownLatch mIdleLatch = new CountDownLatch(2);
+
+ TestLooperThread(Test testMode) {
+ super("TestLooperThread");
+ mTestMode = testMode;
+ }
+
+ @Override
+ protected void onLooperPrepared() {
+ super.onLooperPrepared();
+
+ IdleHandler idleHandler = new IdleHandler() {
+ public boolean queueIdle() {
+ mIdleLatch.countDown();
+ return false;
+ }
+ };
+
+ if (mTestMode == Test.ADD_IDLE_HANDLER) {
+ Looper.myQueue().addIdleHandler(idleHandler);
+ } else {
+ Looper.myQueue().addIdleHandler(idleHandler);
+ Looper.myQueue().removeIdleHandler(idleHandler);
+ }
+ }
+
+ @Override
+ public void run() {
+ mIdleLatch.countDown();
+ super.run();
+ }
+
+ public boolean hasIdleHandlerBeenCalled() throws InterruptedException {
+ return mIdleLatch.await(TIMEOUT, TimeUnit.MILLISECONDS);
+ }
+
+ public long getTestProgress() {
+ return mIdleLatch.getCount();
+ }
}
/**
@@ -155,68 +167,6 @@
}
/**
- * Helper class used to test addIdleHandler, removeIdleHandler
- */
- private class MessageQueueTestHelper {
-
- private boolean mDone;
- private Looper mLooper;
-
- public void doTest(long timeout, long interval) throws InterruptedException {
- (new LooperThread()).start();
- synchronized (this) {
- long now = System.currentTimeMillis();
- long endTime = now + timeout;
- // Wait and frequently check if mDone is set.
- while (!mDone && now < endTime) {
- wait(interval);
- now = System.currentTimeMillis();
- }
- }
- mLooper.quit();
- if (!mDone) {
- throw new RuntimeException("test timed out");
- }
- }
-
- private class LooperThread extends HandlerThread {
- public LooperThread() {
- super("MessengeQueueLooperThread");
- }
-
- public void onLooperPrepared() {
- mLooper = getLooper();
- if (mActionFlag) {
- // If mActionFlag is true, just addIdleHandler, and
- // Looper.loop() will set mResult true.
- Looper.myQueue().addIdleHandler(mIdleHandler);
- } else {
- // If mActionFlag is false, addIdleHandler and remove it, then Looper.loop()
- // will not set mResult true because the idleHandler list is empty.
- Looper.myQueue().addIdleHandler(mIdleHandler);
- Looper.myQueue().removeIdleHandler(mIdleHandler);
- }
- }
-
- @Override
- public void run() {
- super.run();
- synchronized (MessageQueueTestHelper.this) {
- mDone = true;
- MessageQueueTestHelper.this.notifyAll();
- }
- }
- }
-
- public void quit() {
- synchronized (this) {
- mDone = true;
- notifyAll();
- }
- }
- }
-
- /**
* Helper class used to test sending message to message queue.
*/
private class OrderTestHelper {
diff --git a/tests/tests/permission/src/android/permission/cts/NoActivityRelatedPermissionTest.java b/tests/tests/permission/src/android/permission/cts/NoActivityRelatedPermissionTest.java
index 1e12455..fab9cf6 100644
--- a/tests/tests/permission/src/android/permission/cts/NoActivityRelatedPermissionTest.java
+++ b/tests/tests/permission/src/android/permission/cts/NoActivityRelatedPermissionTest.java
@@ -16,7 +16,6 @@
package android.permission.cts;
-import dalvik.annotation.BrokenTest;
import dalvik.annotation.TestTargetClass;
import android.app.Activity;
diff --git a/tests/tests/permission/src/android/permission/cts/NoCallPermissionTest.java b/tests/tests/permission/src/android/permission/cts/NoCallPermissionTest.java
deleted file mode 100644
index 6e86967..0000000
--- a/tests/tests/permission/src/android/permission/cts/NoCallPermissionTest.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright (C) 2009 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.permission.cts;
-
-import android.content.Intent;
-import android.net.Uri;
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.SmallTest;
-
-/**
- * Verify Phone calling related methods without specific Phone/Call permissions.
- */
-public class NoCallPermissionTest extends AndroidTestCase {
-
- /**
- * Verify that Intent.ACTION_CALL requires permissions.
- * <p>Requires Permission:
- * {@link android.Manifest.permission#CALL_PHONE}.
- */
- @SmallTest
- public void testActionCall() {
- Uri uri = Uri.parse("tel:123456");
- Intent intent = new Intent(Intent.ACTION_CALL, uri);
- intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- try {
- mContext.startActivity(intent);
- fail("startActivity(Intent.ACTION_CALL) did not throw SecurityException as expected");
- } catch (SecurityException e) {
- // expected
- }
- }
-
- /**
- * Verify that Intent.ACTION_CALL_PRIVILEGED requires permissions.
- * <p>Requires Permission:
- * {@link android.Manifest.permission#CALL_PRIVILEGED}.
- */
- @SmallTest
- public void testCallVoicemail() {
- try {
- //Intent intent = new Intent(Intent.ACTION_CALL_PRIVILEGED,
- Intent intent = new Intent("android.intent.action.CALL_PRIVILEGED",
- Uri.fromParts("voicemail", "", null));
- intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- mContext.startActivity(intent);
- fail("startActivity(Intent.ACTION_CALL_PRIVILEGED) did not throw SecurityException as expected");
- } catch (SecurityException e) {
- // expected
- }
- }
-
- /**
- * Verify that Intent.ACTION_CALL_PRIVILEGED requires permissions.
- * <p>Requires Permission:
- * {@link android.Manifest.permission#CALL_PRIVILEGED}.
- */
- @SmallTest
- public void testCall911() {
- //Intent intent = new Intent(Intent.ACTION_CALL_PRIVILEGED, Uri.parse("tel:911"));
- Intent intent = new Intent("android.intent.action.CALL_PRIVILEGED", Uri.parse("tel:911"));
- intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- try {
- mContext.startActivity(intent);
- fail("startActivity(Intent.ACTION_CALL_PRIVILEGED) did not throw SecurityException as expected");
- } catch (SecurityException e) {
- // expected
- }
- }
-
-}
diff --git a/tests/tests/webkit/src/android/webkit/cts/WebChromeClientTest.java b/tests/tests/webkit/src/android/webkit/cts/WebChromeClientTest.java
index ff10ca5..cf20217 100644
--- a/tests/tests/webkit/src/android/webkit/cts/WebChromeClientTest.java
+++ b/tests/tests/webkit/src/android/webkit/cts/WebChromeClientTest.java
@@ -115,6 +115,42 @@
@TestTargets({
@TestTargetNew(
level = TestLevel.COMPLETE,
+ method = "onReceivedIcon",
+ args = {WebView.class, Bitmap.class}
+ )
+ })
+ public void testOnReceivedIcon() throws Throwable {
+ final MockWebChromeClient webChromeClient = new MockWebChromeClient();
+ mWebView.setWebChromeClient(webChromeClient);
+
+ runTestOnUiThread(new Runnable() {
+
+ @Override
+ public void run() {
+ // getInstance must run on the UI thread
+ WebIconDatabase mIconDb = WebIconDatabase.getInstance();
+ String dbPath = getActivity().getFilesDir().toString() + "/icons";
+ mIconDb.open(dbPath);
+ mIconDb.removeAllIcons();
+ }
+ });
+
+ assertFalse(webChromeClient.hadOnReceivedIcon());
+
+ String url = mWebServer.getAssetUrl(TestHtmlConstants.HELLO_WORLD_URL);
+ mWebView.loadUrl(url);
+
+ new DelayedCheck(TEST_TIMEOUT) {
+ @Override
+ protected boolean check() {
+ return webChromeClient.hadOnReceivedIcon();
+ }
+ }.run();
+ }
+
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
method = "onCreateWindow",
args = {WebView.class, boolean.class, boolean.class, Message.class}
),
diff --git a/tests/tests/widget/src/android/widget/cts/ProgressBarTest.java b/tests/tests/widget/src/android/widget/cts/ProgressBarTest.java
index 4c5c717..1b9b517 100644
--- a/tests/tests/widget/src/android/widget/cts/ProgressBarTest.java
+++ b/tests/tests/widget/src/android/widget/cts/ProgressBarTest.java
@@ -18,7 +18,6 @@
import com.android.cts.stub.R;
-import dalvik.annotation.BrokenTest;
import dalvik.annotation.TestLevel;
import dalvik.annotation.TestTargetClass;
import dalvik.annotation.TestTargetNew;
@@ -26,7 +25,6 @@
import dalvik.annotation.ToBeFixed;
import android.content.Context;
-import android.content.res.Resources.NotFoundException;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.drawable.Drawable;
@@ -34,7 +32,6 @@
import android.test.InstrumentationTestCase;
import android.view.View;
import android.view.animation.AccelerateDecelerateInterpolator;
-import android.view.animation.CycleInterpolator;
import android.view.animation.Interpolator;
import android.view.animation.LinearInterpolator;
import android.widget.ProgressBar;
@@ -72,7 +69,7 @@
new ProgressBar(mContext, null);
- new ProgressBar(mContext, null, com.android.internal.R.attr.progressBarStyle);
+ new ProgressBar(mContext, null, android.R.attr.progressBarStyle);
}
@TestTargets({
@@ -98,8 +95,7 @@
// because default is Indeterminate only progressBar, can't change the status
assertTrue(progressBar.isIndeterminate());
- progressBar = new ProgressBar(mContext, null,
- com.android.internal.R.attr.progressBarStyleHorizontal);
+ progressBar = new ProgressBar(mContext, null, android.R.attr.progressBarStyleHorizontal);
assertFalse(progressBar.isIndeterminate());
progressBar.setIndeterminate(true);
@@ -152,7 +148,7 @@
})
public void testAccessProgressDrawable() {
ProgressBar progressBar = new ProgressBar(mContext, null,
- com.android.internal.R.attr.progressBarStyleHorizontal);
+ android.R.attr.progressBarStyleHorizontal);
// set ProgressDrawable
// normal value
@@ -182,7 +178,7 @@
})
public void testAccessProgress() {
ProgressBar progressBar = new ProgressBar(mContext, null,
- com.android.internal.R.attr.progressBarStyleHorizontal);
+ android.R.attr.progressBarStyleHorizontal);
assertEquals(0, progressBar.getProgress());
final int maxProgress = progressBar.getMax();
@@ -221,7 +217,7 @@
})
public void testAccessSecondaryProgress() {
ProgressBar progressBar = new ProgressBar(mContext, null,
- com.android.internal.R.attr.progressBarStyleHorizontal);
+ android.R.attr.progressBarStyleHorizontal);
assertEquals(0, progressBar.getSecondaryProgress());
final int maxProgress = progressBar.getMax();
@@ -253,7 +249,7 @@
)
public void testIncrementProgressBy() {
ProgressBar progressBar = new ProgressBar(mContext, null,
- com.android.internal.R.attr.progressBarStyleHorizontal);
+ android.R.attr.progressBarStyleHorizontal);
// normal value
int increment = 1;
@@ -283,7 +279,7 @@
)
public void testIncrementSecondaryProgressBy() {
ProgressBar progressBar = new ProgressBar(mContext, null,
- com.android.internal.R.attr.progressBarStyleHorizontal);
+ android.R.attr.progressBarStyleHorizontal);
// normal value
int increment = 1;
@@ -319,8 +315,7 @@
)
})
public void testAccessInterpolator() {
- ProgressBar progressBar = new ProgressBar(mContext, null,
- com.android.internal.R.attr.progressBarStyle);
+ ProgressBar progressBar = new ProgressBar(mContext);
// default should be LinearInterpolator
assertTrue(progressBar.getInterpolator() instanceof LinearInterpolator);
@@ -329,54 +324,6 @@
Interpolator i = new AccelerateDecelerateInterpolator();
progressBar.setInterpolator(i);
assertEquals(i, progressBar.getInterpolator());
-
- // exceptional value
- progressBar.setInterpolator(null);
- assertNull(progressBar.getInterpolator());
-
- // TODO: test whether setInterpolator takes effect? How to get the animation?
- }
-
- @TestTargets({
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- method = "setInterpolator",
- args = {android.content.Context.class, int.class}
- ),
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- method = "getInterpolator",
- args = {}
- )
- })
- @ToBeFixed(bug = "1695243", explanation = "the javadoc for setInterpolator() is incomplete." +
- "1. not clear what is supposed to happen if context or resID is exceptional.")
- @BrokenTest("Initial setInterpolator() call occasionally fails with NPE. context null?")
- public void testAccessInterpolatorContext() {
- ProgressBar progressBar = new ProgressBar(mContext, null,
- com.android.internal.R.attr.progressBarStyle);
-
- // default is LinearInterpolator
- assertTrue(progressBar.getInterpolator() instanceof LinearInterpolator);
-
- // normal value
- progressBar.setInterpolator(mContext.getApplicationContext(), R.anim.move_cycle);
- assertTrue(progressBar.getInterpolator() instanceof CycleInterpolator);
-
- // exceptional value
- try {
- progressBar.setInterpolator(null, R.anim.move_ani);
- fail("Should throw NullPointerException");
- } catch (NullPointerException e) {
- // issue 1695243, not clear what is supposed to happen if context is null.
- }
-
- try {
- progressBar.setInterpolator(mContext.getApplicationContext(), -1);
- fail("Should throw NotFoundException");
- } catch (NotFoundException e) {
- // issue 1695243, not clear what is supposed to happen if resID is exceptional.
- }
}
@TestTargetNew(
@@ -388,7 +335,7 @@
"1. not clear what is supposed result if visibility isn't VISIBLE, INVISIBLE or GONE.")
public void testSetVisibility() {
ProgressBar progressBar = new ProgressBar(mContext, null,
- com.android.internal.R.attr.progressBarStyleHorizontal);
+ android.R.attr.progressBarStyleHorizontal);
// set visibility
// normal value
@@ -472,7 +419,7 @@
})
public void testAccessMax() {
ProgressBar progressBar = new ProgressBar(mContext, null,
- com.android.internal.R.attr.progressBarStyleHorizontal);
+ android.R.attr.progressBarStyleHorizontal);
// set Progress
int progress = 10;
@@ -612,7 +559,7 @@
})
public void testOnSaveAndRestoreInstanceState() {
ProgressBar progressBar = new ProgressBar(mContext, null,
- com.android.internal.R.attr.progressBarStyleHorizontal);
+ android.R.attr.progressBarStyleHorizontal);
int oldProgress = 1;
int oldSecondaryProgress = progressBar.getMax() - 1;
progressBar.setProgress(oldProgress);
diff --git a/tests/tests/widget/src/android/widget/cts/RemoteViewsTest.java b/tests/tests/widget/src/android/widget/cts/RemoteViewsTest.java
index aaeac6e..ddbe90d 100644
--- a/tests/tests/widget/src/android/widget/cts/RemoteViewsTest.java
+++ b/tests/tests/widget/src/android/widget/cts/RemoteViewsTest.java
@@ -18,7 +18,6 @@
import com.android.cts.stub.R;
-import dalvik.annotation.BrokenTest;
import dalvik.annotation.TestLevel;
import dalvik.annotation.TestTargetClass;
import dalvik.annotation.TestTargetNew;
@@ -219,14 +218,11 @@
method = "setImageViewUri",
args = {int.class, android.net.Uri.class}
)
- @BrokenTest("needs investigation")
public void testSetImageViewUri() throws IOException {
- File imageFile = null;
+ String path = getTestImagePath();
+ File imageFile = new File(path);
try {
- // create the test image first
- String path = getTestImagePath();
- imageFile = new File(path);
createSampleImage(imageFile, R.raw.testimage);
Uri uri = Uri.parse(path);
@@ -235,15 +231,13 @@
mRemoteViews.setImageViewUri(R.id.remoteView_image, uri);
mRemoteViews.reapply(mActivity, mResult);
- BitmapDrawable d = (BitmapDrawable) mActivity
- .getResources().getDrawable(R.drawable.testimage);
- WidgetTestUtils.assertEquals(d.getBitmap(),
- ((BitmapDrawable) image.getDrawable()).getBitmap());
+
+ Bitmap imageViewBitmap = ((BitmapDrawable) image.getDrawable()).getBitmap();
+ Bitmap expectedBitmap = WidgetTestUtils.getUnscaledAndDitheredBitmap(
+ mActivity.getResources(), R.raw.testimage, imageViewBitmap.getConfig());
+ WidgetTestUtils.assertEquals(expectedBitmap, imageViewBitmap);
} finally {
- if (imageFile != null) {
- // remove the test image file
- imageFile.delete();
- }
+ imageFile.delete();
}
}
@@ -597,34 +591,36 @@
method = "setUri",
args = {int.class, java.lang.String.class, android.net.Uri.class}
)
- @BrokenTest("needs investigation")
public void testSetUri() throws IOException {
- // create the test image first
String path = getTestImagePath();
File imagefile = new File(path);
- createSampleImage(imagefile, R.raw.testimage);
- Uri uri = Uri.parse(path);
- ImageView image = (ImageView) mResult.findViewById(R.id.remoteView_image);
- assertNull(image.getDrawable());
-
- mRemoteViews.setUri(R.id.remoteView_image, "setImageURI", uri);
- mRemoteViews.reapply(mActivity, mResult);
- BitmapDrawable d = (BitmapDrawable) mActivity
- .getResources().getDrawable(R.drawable.testimage);
- WidgetTestUtils.assertEquals(d.getBitmap(),
- ((BitmapDrawable) image.getDrawable()).getBitmap());
-
- mRemoteViews.setUri(R.id.remoteView_absolute, "setImageURI", uri);
try {
- mRemoteViews.reapply(mActivity, mResult);
- fail("Should throw ActionException");
- } catch (ActionException e) {
- // expected
- }
+ createSampleImage(imagefile, R.raw.testimage);
- // remove the test image file
- imagefile.delete();
+ Uri uri = Uri.parse(path);
+ ImageView image = (ImageView) mResult.findViewById(R.id.remoteView_image);
+ assertNull(image.getDrawable());
+
+ mRemoteViews.setUri(R.id.remoteView_image, "setImageURI", uri);
+ mRemoteViews.reapply(mActivity, mResult);
+
+ Bitmap imageViewBitmap = ((BitmapDrawable) image.getDrawable()).getBitmap();
+ Bitmap expectedBitmap = WidgetTestUtils.getUnscaledAndDitheredBitmap(
+ mActivity.getResources(), R.raw.testimage, imageViewBitmap.getConfig());
+ WidgetTestUtils.assertEquals(expectedBitmap, imageViewBitmap);
+
+ mRemoteViews.setUri(R.id.remoteView_absolute, "setImageURI", uri);
+ try {
+ mRemoteViews.reapply(mActivity, mResult);
+ fail("Should throw ActionException");
+ } catch (ActionException e) {
+ // expected
+ }
+ } finally {
+ // remove the test image file
+ imagefile.delete();
+ }
}
@TestTargetNew(