Reconcile with ics-mr1-release
Change-Id: I626c1244f5c6c6c813dc2d607b844287bdbbdccc
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/PassFailButtons.java b/apps/CtsVerifier/src/com/android/cts/verifier/PassFailButtons.java
index 9991b9d..e7bf70d 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/PassFailButtons.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/PassFailButtons.java
@@ -76,9 +76,6 @@
Button getPassButton();
- /* Added to the interface just to make sure it isn't forgotten in the implementations. */
- Dialog onCreateDialog(int id, Bundle args);
-
/**
* Returns a unique identifier for the test. Usually, this is just the class name.
*/
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/audioquality/Experiment.java b/apps/CtsVerifier/src/com/android/cts/verifier/audioquality/Experiment.java
index 6f2aa83..bd5f186 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/audioquality/Experiment.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/audioquality/Experiment.java
@@ -27,7 +27,7 @@
* The base class for all audio experiments.
*/
public class Experiment implements Runnable {
- protected static final String TAG = "AudioQualityVerifier";
+ private static final String TAG = "AudioQualityVerifier";
private static final int DEFAULT_TIMEOUT = 5; // In seconds
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/audioquality/experiments/LoopbackExperiment.java b/apps/CtsVerifier/src/com/android/cts/verifier/audioquality/experiments/LoopbackExperiment.java
index 109fdfe..0817860 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/audioquality/experiments/LoopbackExperiment.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/audioquality/experiments/LoopbackExperiment.java
@@ -35,6 +35,8 @@
* the test results (score and report).
*/
public class LoopbackExperiment extends Experiment {
+ private static final String TAG = "LoopbackExperiment";
+
protected static final int TIMEOUT = 10;
// Amount of silence in ms before and after playback
diff --git a/tests/core/libcore/src/Dummy.java b/tests/core/libcore/src/Dummy.java
index cfe0c81..64b67de 100644
--- a/tests/core/libcore/src/Dummy.java
+++ b/tests/core/libcore/src/Dummy.java
@@ -17,7 +17,7 @@
/**
* We really just want the core-tests classes from the static java
* library, but the build system currently needs at least one input
- * file, not just becuase its a sanity check, but because the static
+ * file, not just because its a sanity check, but because the static
* class files and resources are included in the output of the local
* java compilation.
*/
diff --git a/tests/tests/graphics/src/android/graphics/drawable/cts/GradientDrawableTest.java b/tests/tests/graphics/src/android/graphics/drawable/cts/GradientDrawableTest.java
index 6849c69..d2599e4 100644
--- a/tests/tests/graphics/src/android/graphics/drawable/cts/GradientDrawableTest.java
+++ b/tests/tests/graphics/src/android/graphics/drawable/cts/GradientDrawableTest.java
@@ -449,7 +449,7 @@
method = "getConstantState",
args = {}
)
- @ToBeFixed(bug = "", explanation = "can not assert the inner fields, becuase the class" +
+ @ToBeFixed(bug = "", explanation = "can not assert the inner fields, because the class" +
" GradientState is package protected.")
public void testGetConstantState() {
GradientDrawable gradientDrawable = new GradientDrawable();
diff --git a/tests/tests/graphics/src/android/graphics/drawable/cts/InsetDrawableTest.java b/tests/tests/graphics/src/android/graphics/drawable/cts/InsetDrawableTest.java
index 32dc5ca..c3a0b45 100644
--- a/tests/tests/graphics/src/android/graphics/drawable/cts/InsetDrawableTest.java
+++ b/tests/tests/graphics/src/android/graphics/drawable/cts/InsetDrawableTest.java
@@ -431,7 +431,7 @@
method = "getConstantState",
args = {}
)
- @ToBeFixed(bug = "", explanation = "can not assert the inner fields, becuase the class" +
+ @ToBeFixed(bug = "", explanation = "can not assert the inner fields, because the class" +
" InsetState is package protected.")
public void testGetConstantState() {
Drawable d = mContext.getResources().getDrawable(R.drawable.pass);
diff --git a/tests/tests/hardware/src/android/hardware/cts/CameraTest.java b/tests/tests/hardware/src/android/hardware/cts/CameraTest.java
old mode 100644
new mode 100755
diff --git a/tests/tests/net/Android.mk b/tests/tests/net/Android.mk
index 1fd9ba0..bf51890 100644
--- a/tests/tests/net/Android.mk
+++ b/tests/tests/net/Android.mk
@@ -23,12 +23,12 @@
LOCAL_JAVA_LIBRARIES := android.test.runner
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
+# include CtsTestServer as a temporary hack to free net.cts from cts.stub.
+LOCAL_SRC_FILES := $(call all-java-files-under, src) \
+ ../../src/android/webkit/cts/CtsTestServer.java
LOCAL_PACKAGE_NAME := CtsNetTestCases
-LOCAL_INSTRUMENTATION_FOR := CtsTestStubs
-
# uncomment when dalvik.annotation.Test* are removed or part of SDK
#LOCAL_SDK_VERSION := current
diff --git a/tests/tests/net/AndroidManifest.xml b/tests/tests/net/AndroidManifest.xml
index a1f632e..4fa0565 100644
--- a/tests/tests/net/AndroidManifest.xml
+++ b/tests/tests/net/AndroidManifest.xml
@@ -18,12 +18,20 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.cts.net">
+ <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
+ <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
+ <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
+ <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
+ <uses-permission android:name="android.permission.INTERNET" />
+ <uses-permission android:name="android.permission.WAKE_LOCK" />
+ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+
<application>
<uses-library android:name="android.test.runner" />
</application>
- <instrumentation android:name="android.test.InstrumentationCtsTestRunner"
- android:targetPackage="com.android.cts.stub"
+ <instrumentation android:name="android.test.InstrumentationTestRunner"
+ android:targetPackage="com.android.cts.net"
android:label="CTS tests of android.net"/>
</manifest>
diff --git a/tests/tests/net/src/android/net/cts/VpnServiceTest.java b/tests/tests/net/src/android/net/cts/VpnServiceTest.java
new file mode 100644
index 0000000..9e35375
--- /dev/null
+++ b/tests/tests/net/src/android/net/cts/VpnServiceTest.java
@@ -0,0 +1,120 @@
+/*
+ * Copyright (C) 2012 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.net.cts;
+
+import android.content.Intent;
+import android.net.VpnService;
+import android.os.ParcelFileDescriptor;
+import android.test.AndroidTestCase;
+
+import java.io.File;
+import java.net.DatagramSocket;
+import java.net.Socket;
+
+/**
+ * VpnService API is built with security in mind. However, its security also
+ * blocks us from writing tests for positive cases. For now we only test for
+ * negative cases, and we will try to cover the rest in the future.
+ */
+public class VpnServiceTest extends AndroidTestCase {
+
+ private static final String TAG = VpnServiceTest.class.getSimpleName();
+
+ private VpnService mVpnService = new VpnService();
+
+ public void testPrepare() throws Exception {
+ // Should never return null since we are not prepared.
+ Intent intent = VpnService.prepare(mContext);
+ assertNotNull(intent);
+
+ // Should be always resolved by only one activity.
+ int count = mContext.getPackageManager().queryIntentActivities(intent, 0).size();
+ assertEquals(count, 1);
+ }
+
+ public void testEstablish() throws Exception {
+ ParcelFileDescriptor descriptor = null;
+ try {
+ // Should always return null since we are not prepared.
+ descriptor = mVpnService.new Builder().addAddress("8.8.8.8", 30).establish();
+ assertNull(descriptor);
+ } finally {
+ try {
+ descriptor.close();
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+ }
+
+ public void testProtect_DatagramSocket() throws Exception {
+ DatagramSocket socket = new DatagramSocket();
+ try {
+ // Should always return false since we are not prepared.
+ assertFalse(mVpnService.protect(socket));
+ } finally {
+ try {
+ socket.close();
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+ }
+
+ public void testProtect_Socket() throws Exception {
+ Socket socket = new Socket();
+ try {
+ // Should always return false since we are not prepared.
+ assertFalse(mVpnService.protect(socket));
+ } finally {
+ try {
+ socket.close();
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+ }
+
+ public void testProtect_int() throws Exception {
+ DatagramSocket socket = new DatagramSocket();
+ ParcelFileDescriptor descriptor = ParcelFileDescriptor.fromDatagramSocket(socket);
+ try {
+ // Should always return false since we are not prepared.
+ assertFalse(mVpnService.protect(descriptor.getFd()));
+ } finally {
+ try {
+ descriptor.close();
+ } catch (Exception e) {
+ // ignore
+ }
+ try {
+ socket.close();
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+ }
+
+ public void testTunDevice() throws Exception {
+ File file = new File("/dev/tun");
+ assertTrue(file.exists());
+ assertFalse(file.isFile());
+ assertFalse(file.isDirectory());
+ assertFalse(file.canExecute());
+ assertFalse(file.canRead());
+ assertFalse(file.canWrite());
+ }
+}
diff --git a/tests/tests/security/src/android/security/cts/VoldExploitTest.java b/tests/tests/security/src/android/security/cts/VoldExploitTest.java
index ab14f12..d4ea884 100644
--- a/tests/tests/security/src/android/security/cts/VoldExploitTest.java
+++ b/tests/tests/security/src/android/security/cts/VoldExploitTest.java
@@ -269,12 +269,18 @@
/**
* Poll /proc/net/netlink until all the "Rmem" fields contain
- * "0". This indicates that there are no outstanding unreceived
- * netlink messages.
+ * "0" or approximately 10 seconds have passed.
+ *
+ * This indicates that either the netlink message was received,
+ * or the process took too long to process the incoming netlink
+ * message.
+ *
+ * See http://code.google.com/p/android/issues/detail?id=25099
+ * for information on why the timeout is needed.
*/
private static void confirmNetlinkMsgReceived() {
try {
- while(true) {
+ for (int ct = 0; ct < 200; ct++) {
boolean foundAllZeros = true;
for (List<String> i : parseNetlink()) {
// Column 5 is the "Rmem" field, which is the
diff --git a/tests/tests/text/src/android/text/format/cts/TimeTest.java b/tests/tests/text/src/android/text/format/cts/TimeTest.java
index 0fb3f2a..50c51da 100644
--- a/tests/tests/text/src/android/text/format/cts/TimeTest.java
+++ b/tests/tests/text/src/android/text/format/cts/TimeTest.java
@@ -627,10 +627,10 @@
)
public void testSetToNow0() throws Exception {
Time t = new Time(Time.TIMEZONE_UTC);
- t.setToNow();
long currentTime = System.currentTimeMillis();
+ t.setToNow();
long time = t.toMillis(false);
- assertEquals(currentTime, time, 500);
+ assertEquals(currentTime, time, 999);
}
@TestTargetNew(
diff --git a/tests/tests/view/src/android/view/cts/OrientationEventListenerTest.java b/tests/tests/view/src/android/view/cts/OrientationEventListenerTest.java
index 570ef88..130f01b 100644
--- a/tests/tests/view/src/android/view/cts/OrientationEventListenerTest.java
+++ b/tests/tests/view/src/android/view/cts/OrientationEventListenerTest.java
@@ -56,7 +56,7 @@
level = TestLevel.SUFFICIENT,
notes = "Test {@link OrientationEventListener#enable()}. "
+ "This method is simply called to make sure that no exception is thrown. "
- + "The registeration of the listener can not be tested becuase there is "
+ + "The registration of the listener can not be tested because there is "
+ "no way to simulate sensor events",
method = "enable",
args = {}
@@ -65,7 +65,7 @@
level = TestLevel.SUFFICIENT,
notes = "Test {@link OrientationEventListener#disable()}. "
+ "This method is simply called to make sure that no exception is thrown. "
- + "The registeration of the listener can not be tested becuase there is "
+ + "The registration of the listener can not be tested because there is "
+ "no way to simulate sensor events",
method = "disable",
args = {}
diff --git a/tests/tests/view/src/android/view/cts/OrientationListenerTest.java b/tests/tests/view/src/android/view/cts/OrientationListenerTest.java
index f21519c..b3437cd 100644
--- a/tests/tests/view/src/android/view/cts/OrientationListenerTest.java
+++ b/tests/tests/view/src/android/view/cts/OrientationListenerTest.java
@@ -65,7 +65,7 @@
level = TestLevel.COMPLETE,
notes = "Test {@link OrientationListener#enable()}. "
+ "This method is simply called to make sure that no exception is thrown. "
- + "The registeration of the listener can not be tested becuase there is no way "
+ + "The registration of the listener can not be tested because there is no way "
+ "to simulate sensor events on the emulator",
method = "enable",
args = {}
@@ -74,14 +74,14 @@
level = TestLevel.COMPLETE,
notes = "Test {@link OrientationListener#disable()}. "
+ "This method is simply called to make sure that no exception is thrown. "
- + "The registeration of the listener can not be tested becuase there is no way "
+ + "The registration of the listener can not be tested because there is no way "
+ "to simulate sensor events on the emulator",
method = "disable",
args = {}
)
})
@ToBeFixed(explanation = "Can not simulate sensor events on the emulator.")
- public void testRegisterationOfOrientationListener() {
+ public void testRegistrationOfOrientationListener() {
// these methods are called to assure that no exception is thrown
MockOrientationListener listener = new MockOrientationListener(mContext);
listener.disable();
diff --git a/tests/tests/widget/src/android/widget/cts/GridViewTest.java b/tests/tests/widget/src/android/widget/cts/GridViewTest.java
index 84c07f7..50a7bae 100755
--- a/tests/tests/widget/src/android/widget/cts/GridViewTest.java
+++ b/tests/tests/widget/src/android/widget/cts/GridViewTest.java
@@ -312,7 +312,8 @@
mGridView.setStretchMode(GridView.NO_STRETCH);
// Number of columns should be big enough, otherwise the
// horizontal spacing cannot be correctly verified.
- mGridView.setNumColumns(22);
+ mGridView.setNumColumns(28);
+
// this test case can not be ran in UI thread.
mActivity.runOnUiThread(new Runnable() {
diff --git a/tools/cts-native-xml-generator/src/Android.mk b/tools/cts-native-xml-generator/src/Android.mk
index 70b9f49..ed93457 100644
--- a/tools/cts-native-xml-generator/src/Android.mk
+++ b/tools/cts-native-xml-generator/src/Android.mk
@@ -20,7 +20,7 @@
include $(CLEAR_VARS)
LOCAL_SRC_FILES := $(call all-subdir-java-files)
-LOCAL_JAVA_RESOURCE_DIRS := res
+LOCAL_JAVA_RESOURCE_DIRS :=
LOCAL_JAR_MANIFEST := MANIFEST.mf
LOCAL_MODULE := cts-native-xml-generator
diff --git a/tools/vm-tests-tf/src/util/build/BuildDalvikSuite.java b/tools/vm-tests-tf/src/util/build/BuildDalvikSuite.java
index bd3f4fd..bd688fe 100644
--- a/tools/vm-tests-tf/src/util/build/BuildDalvikSuite.java
+++ b/tools/vm-tests-tf/src/util/build/BuildDalvikSuite.java
@@ -631,7 +631,7 @@
scanner.close();
}
if (scanner2 != null) {
- scanner.close();
+ scanner2.close();
}
return md;
}
@@ -650,6 +650,7 @@
FileReader reader = new FileReader(file);
char[] charContents = new char[(int) file.length()];
reader.read(charContents);
+ reader.close();
String contents = new String(charContents);
if (contents.equals(content)) {
// System.out.println("skipping identical: "
diff --git a/tools/vm-tests/src/util/build/BuildDalvikSuite.java b/tools/vm-tests/src/util/build/BuildDalvikSuite.java
index eda6382..f08b651 100644
--- a/tools/vm-tests/src/util/build/BuildDalvikSuite.java
+++ b/tools/vm-tests/src/util/build/BuildDalvikSuite.java
@@ -794,7 +794,7 @@
scanner.close();
}
if (scanner2 != null) {
- scanner.close();
+ scanner2.close();
}
return md;
}