Merge "CTS NFC tests: don't write to page 4 on UL tags." into jb-mr1-dev
diff --git a/tests/tests/media/src/android/media/cts/CamcorderProfileTest.java b/tests/tests/media/src/android/media/cts/CamcorderProfileTest.java
index 3f28218..1df5011 100644
--- a/tests/tests/media/src/android/media/cts/CamcorderProfileTest.java
+++ b/tests/tests/media/src/android/media/cts/CamcorderProfileTest.java
@@ -266,6 +266,7 @@
return true;
}
}
+ Log.e(TAG, "Size (" + width + "x" + height + ") is not supported");
return false;
}
}
diff --git a/tests/tests/net/src/android/net/wifi/cts/WifiManagerTest.java b/tests/tests/net/src/android/net/wifi/cts/WifiManagerTest.java
index 5fc23e7..a64477d 100644
--- a/tests/tests/net/src/android/net/wifi/cts/WifiManagerTest.java
+++ b/tests/tests/net/src/android/net/wifi/cts/WifiManagerTest.java
@@ -21,17 +21,22 @@
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
+import android.net.NetworkInfo;
import android.net.wifi.ScanResult;
import android.net.wifi.WifiConfiguration;
-import android.net.wifi.WifiManager;
import android.net.wifi.WifiConfiguration.Status;
+import android.net.wifi.WifiManager;
+import android.net.wifi.WifiManager.TxPacketCountListener;
import android.net.wifi.WifiManager.WifiLock;
import android.test.AndroidTestCase;
import android.util.Log;
+import java.net.HttpURLConnection;
+import java.net.URL;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
+import java.util.concurrent.atomic.AtomicInteger;
public class WifiManagerTest extends AndroidTestCase {
private static class MySync {
@@ -42,6 +47,7 @@
private WifiLock mWifiLock;
private static MySync mMySync;
private List<ScanResult> mScanResult = null;
+ private NetworkInfo mNetworkInfo;
// Please refer to WifiManager
private static final int MIN_RSSI = -100;
@@ -78,6 +84,13 @@
mMySync.expectedState = STATE_WIFI_CHANGED;
mMySync.notify();
}
+ } else if (action.equals(WifiManager.NETWORK_STATE_CHANGED_ACTION)) {
+ synchronized (mMySync) {
+ mNetworkInfo =
+ (NetworkInfo) intent.getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO);
+ if (mNetworkInfo.getState() == NetworkInfo.State.CONNECTED)
+ mMySync.notify();
+ }
}
}
};
@@ -148,6 +161,18 @@
}
}
+ private void connectWifi() throws Exception {
+ synchronized (mMySync) {
+ if (mNetworkInfo.getState() == NetworkInfo.State.CONNECTED) return;
+ assertTrue(mWifiManager.reconnect());
+ long timeout = System.currentTimeMillis() + TIMEOUT_MSEC;
+ while (System.currentTimeMillis() < timeout
+ && mNetworkInfo.getState() != NetworkInfo.State.CONNECTED)
+ mMySync.wait(WAIT_MSEC);
+ assertTrue(mNetworkInfo.getState() == NetworkInfo.State.CONNECTED);
+ }
+ }
+
private boolean existSSID(String ssid) {
for (final WifiConfiguration w : mWifiManager.getConfiguredNetworks()) {
if (w.SSID.equals(ssid))
@@ -339,4 +364,65 @@
rssiB = 4;
assertTrue(WifiManager.compareSignalLevel(rssiA, rssiB) > 0);
}
+
+ private int getTxPacketCount() throws Exception {
+ final AtomicInteger ret = new AtomicInteger(-1);
+
+ mWifiManager.getTxPacketCount(new TxPacketCountListener() {
+ @Override
+ public void onSuccess(int count) {
+ ret.set(count);
+ }
+ @Override
+ public void onFailure(int reason) {
+ ret.set(0);
+ }
+ });
+
+ long timeout = System.currentTimeMillis() + TIMEOUT_MSEC;
+ while (ret.get() < 0 && System.currentTimeMillis() < timeout)
+ Thread.sleep(WAIT_MSEC);
+ assertTrue(ret.get() >= 0);
+ return ret.get();
+ }
+
+ /**
+ * The new WiFi watchdog requires kernel/driver to export some packet loss
+ * counters. This CTS tests whether those counters are correctly exported.
+ * To pass this CTS test, a connected WiFi link is required.
+ */
+ public void testWifiWatchdog() throws Exception {
+ // Make sure WiFi is enabled
+ if (!mWifiManager.isWifiEnabled()) {
+ setWifiEnabled(true);
+ Thread.sleep(DURATION);
+ }
+ assertTrue(mWifiManager.isWifiEnabled());
+
+ // Wait for a WiFi connection
+ connectWifi();
+
+ // Read TX packet counter
+ int txcount1 = getTxPacketCount();
+
+ // Do some network operations
+ HttpURLConnection connection = null;
+ try {
+ URL url = new URL("http://www.google.com/");
+ connection = (HttpURLConnection) url.openConnection();
+ connection.setInstanceFollowRedirects(false);
+ connection.setConnectTimeout(TIMEOUT_MSEC);
+ connection.setReadTimeout(TIMEOUT_MSEC);
+ connection.setUseCaches(false);
+ connection.getInputStream();
+ } catch (Exception e) {
+ // ignore
+ } finally {
+ if (connection != null) connection.disconnect();
+ }
+
+ // Read TX packet counter again and make sure it increases
+ int txcount2 = getTxPacketCount();
+ assertTrue(txcount2 > txcount1);
+ }
}
diff --git a/tests/tests/view/src/android/view/cts/ViewTest.java b/tests/tests/view/src/android/view/cts/ViewTest.java
index 4387564..288552d 100644
--- a/tests/tests/view/src/android/view/cts/ViewTest.java
+++ b/tests/tests/view/src/android/view/cts/ViewTest.java
@@ -61,7 +61,7 @@
import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.view.ViewParent;
-import android.view.WindowManagerImpl;
+import android.view.WindowManager;
import android.view.accessibility.AccessibilityEvent;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
@@ -2730,7 +2730,8 @@
Rect outRect = new Rect();
View view = new View(mActivity);
// mAttachInfo is null
- Display d = WindowManagerImpl.getDefault().getDefaultDisplay();
+ WindowManager wm = (WindowManager)mActivity.getSystemService(Context.WINDOW_SERVICE);
+ Display d = wm.getDefaultDisplay();
view.getWindowVisibleDisplayFrame(outRect);
assertEquals(0, outRect.left);
assertEquals(0, outRect.top);
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/CtsTest.java b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/CtsTest.java
index 78f7412..a79b84e 100644
--- a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/CtsTest.java
+++ b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/CtsTest.java
@@ -51,6 +51,7 @@
import java.lang.System;
import java.lang.Thread;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
@@ -148,6 +149,9 @@
"Interval between each reboot in min. Meaningful only with reboot-per-package option")
private int mRebootIntervalMin = 30;
+
+ private long mPrevRebootTime; // last reboot time
+
/** data structure for a {@link IRemoteTest} and its known tests */
class TestPackage {
private final IRemoteTest mTestForPackage;
@@ -350,8 +354,8 @@
Log.i(LOG_TAG, "Initial reboot for multiple packages");
rebootDevice();
}
- long prevTime = System.currentTimeMillis();
- long intervalInMSec = mRebootIntervalMin * 60 * 1000;
+ mPrevRebootTime = System.currentTimeMillis();
+
while (!mRemainingTestPkgs.isEmpty()) {
TestPackage knownTests = mRemainingTestPkgs.get(0);
@@ -367,15 +371,7 @@
test.run(filter);
mRemainingTestPkgs.remove(0);
if (mRemainingTestPkgs.size() > 0) {
- if (mRebootPerPackage) {
- long currentTime = System.currentTimeMillis();
- if ((currentTime - prevTime) > intervalInMSec) {
- Log.i(LOG_TAG, String.format("Rebooting after running package %s",
- knownTests.getPackageDef().getName()));
- rebootDevice();
- prevTime = System.currentTimeMillis();
- }
- }
+ rebootIfNecessary(knownTests, mRemainingTestPkgs.get(0));
// remove artifacts like status bar from the previous test.
// But this cannot dismiss dialog popped-up.
changeToHomeScreen();
@@ -398,6 +394,33 @@
}
}
+ private void rebootIfNecessary(TestPackage testFinished, TestPackage testToRun)
+ throws DeviceNotAvailableException {
+ // If there comes spurious failure like INJECT_EVENTS for a package,
+ // reboot it before running it.
+ // Also reboot after package which is know to leave pop-up behind
+ final List<String> rebootAfterList = Arrays.asList("CtsWebkitSecurityTestCases");
+ final List<String> rebootBeforeList = Arrays.asList("CtsAnimationTestCases",
+ "CtsGraphicsTestCases",
+ "CtsViewTestCases",
+ "CtsWebkitSecurityTestCases",
+ "CtsWidgetTestCases" );
+ long intervalInMSec = mRebootIntervalMin * 60 * 1000;
+ if (mRebootPerPackage) {
+ long currentTime = System.currentTimeMillis();
+ if (((currentTime - mPrevRebootTime) > intervalInMSec) ||
+ rebootAfterList.contains(testFinished.getPackageDef().getName()) ||
+ rebootBeforeList.contains(testToRun.getPackageDef().getName()) ) {
+ Log.i(LOG_TAG,
+ String.format("Rebooting after running package %s, before package %s",
+ testFinished.getPackageDef().getName(),
+ testToRun.getPackageDef().getName()));
+ rebootDevice();
+ mPrevRebootTime = System.currentTimeMillis();
+ }
+ }
+ }
+
private void rebootDevice() throws DeviceNotAvailableException {
final int TIMEOUT_MS = 4 * 60 * 1000;
TestDeviceOptions options = mDevice.getOptions();
diff --git a/tools/utils/buildCts.py b/tools/utils/buildCts.py
index 60c9084..ada706c 100755
--- a/tools/utils/buildCts.py
+++ b/tools/utils/buildCts.py
@@ -124,6 +124,19 @@
plan.Include(r'android\.tests\.appsecurity')
self.__WritePlan(plan, 'AppSecurity')
+ # hard-coded white list for PDK plan
+ plan.Exclude('.*')
+ plan.Include('android\.bluetooth')
+ plan.Include('android\.graphics.*')
+ plan.Include('android\.hardware')
+ plan.Include('android\.media.*')
+ plan.Include('android\.net')
+ plan.Include('android\.opengl.*')
+ plan.Include('android\.renderscript')
+ plan.Include('android\.telephony')
+ plan.Include('android\.nativemedia.*')
+ self.__WritePlan(plan, 'PDK')
+
def LogGenerateDescription(name):
print 'Generating test description for package %s' % name
diff --git a/tools/vm-tests-tf/Android.mk b/tools/vm-tests-tf/Android.mk
index 07a3cf8..71d5fe3 100644
--- a/tools/vm-tests-tf/Android.mk
+++ b/tools/vm-tests-tf/Android.mk
@@ -42,6 +42,7 @@
include $(CLEAR_VARS)
+LOCAL_UNINSTALLABLE_MODULE := true
LOCAL_IS_HOST_MODULE := true
LOCAL_MODULE_CLASS := EXECUTABLES
LOCAL_MODULE := vm-tests-tf