Cleanup of CTS Preconditions work
- removed unused constant from ScreenLockHelper class
- used getProperty method of ITestDevice, instead of executeShellCommand
- modified BuildCheckTest to reflect use of 'getProperty' method above
- placed target preparer for Wifi check above apk installer, so apk
isn't installed until precondition check has passed
- removed unused imports in net module's PreconditionsTest
- added Wifi precondition check to content, text, webkit & widget modules
bug:23939594
Change-Id: I125b9937b974d142c0d2343f584516bfc713787a
diff --git a/common/device-side/preconditions/src/com/android/compatibility/common/preconditions/ScreenLockHelper.java b/common/device-side/preconditions/src/com/android/compatibility/common/preconditions/ScreenLockHelper.java
index 89bc5ba..d2380af 100644
--- a/common/device-side/preconditions/src/com/android/compatibility/common/preconditions/ScreenLockHelper.java
+++ b/common/device-side/preconditions/src/com/android/compatibility/common/preconditions/ScreenLockHelper.java
@@ -24,8 +24,6 @@
*/
public class ScreenLockHelper {
- private final static String PASSWORD_TYPE_KEY = "lockscreen.password_type";
-
/*
* This helper returns false for the Screen Lock set to 'Swipe' or 'None', as it seems there
* is no way to programmatically distinguish between the two.
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/BuildCheck.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/BuildCheck.java
index 4b9a84c..a6a83a7 100644
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/BuildCheck.java
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/BuildCheck.java
@@ -47,7 +47,7 @@
@Override
public void run(ITestDevice device, IBuildInfo buildInfo) throws TargetSetupError,
BuildError, DeviceNotAvailableException {
- String deviceBuildType = device.executeShellCommand("getprop ro.build.type").trim();
+ String deviceBuildType = device.getProperty("ro.build.type");
if (!mExpectedBuildType.name().equalsIgnoreCase(deviceBuildType)) {
String msg = String.format("Expected build type \"%s\" but found build type \"%s\"",
mExpectedBuildType.name().toLowerCase(), deviceBuildType);
diff --git a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/targetprep/BuildCheckTest.java b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/targetprep/BuildCheckTest.java
index b10ecfa..9ba4601 100644
--- a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/targetprep/BuildCheckTest.java
+++ b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/targetprep/BuildCheckTest.java
@@ -40,8 +40,7 @@
mMockDevice = EasyMock.createMock(ITestDevice.class);
mMockBuildInfo = new DeviceBuildInfo("0", "", "");
mOptionSetter = new OptionSetter(mBuildCheck);
- EasyMock.expect(mMockDevice.executeShellCommand(
- "getprop ro.build.type")).andReturn("\nuser\n").anyTimes();
+ EasyMock.expect(mMockDevice.getProperty("ro.build.type")).andReturn("user").anyTimes();
}
public void testWarningMatch() throws Exception {
diff --git a/tests/tests/content/Android.mk b/tests/tests/content/Android.mk
index 0b3b19f..4937814 100644
--- a/tests/tests/content/Android.mk
+++ b/tests/tests/content/Android.mk
@@ -38,3 +38,5 @@
LOCAL_COMPATIBILITY_SUITE := cts_v2
include $(BUILD_CTS_PACKAGE)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/tests/tests/content/AndroidTest.xml b/tests/tests/content/AndroidTest.xml
index de684b5..b4b674c 100644
--- a/tests/tests/content/AndroidTest.xml
+++ b/tests/tests/content/AndroidTest.xml
@@ -15,9 +15,13 @@
-->
<configuration description="Configuration for content Tests">
<include name="common-config" />
+ <target_preparer class="com.android.compatibility.common.tradefed.targetprep.ApkPreconditionCheck">
+ <option name="apk" value="CtsContentPreconditions.apk"/>
+ <option name="package" value="android.content.preconditions"/>
+ </target_preparer>
<option name="apk-installer:test-file-name" value="CtsContentTestCases.apk" />
<test class="com.android.tradefed.testtype.InstrumentationTest" >
<option name="package" value="android.content.cts" />
<option name="runner" value="android.support.test.runner.AndroidJUnitRunner" />
</test>
-</configuration>
\ No newline at end of file
+</configuration>
diff --git a/tests/tests/content/preconditions/Android.mk b/tests/tests/content/preconditions/Android.mk
new file mode 100644
index 0000000..8ffb7ea
--- /dev/null
+++ b/tests/tests/content/preconditions/Android.mk
@@ -0,0 +1,39 @@
+# Copyright (C) 2015 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_DEX_PREOPT := false
+
+LOCAL_PROGUARD_ENABLED := disabled
+
+LOCAL_STATIC_JAVA_LIBRARIES := android-support-test compatibility-device-preconditions
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+LOCAL_PACKAGE_NAME := CtsContentPreconditions
+
+# Tag this module as a cts_v2 test artifact
+LOCAL_COMPATIBILITY_SUITE := cts_v2
+
+LOCAL_SDK_VERSION := current
+
+include $(BUILD_PACKAGE)
diff --git a/tests/tests/content/preconditions/AndroidManifest.xml b/tests/tests/content/preconditions/AndroidManifest.xml
new file mode 100644
index 0000000..1304b81
--- /dev/null
+++ b/tests/tests/content/preconditions/AndroidManifest.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2015 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="android.content.preconditions">
+ <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
+ <application>
+ <uses-library android:name="android.test.runner" />
+ </application>
+
+ <!-- self-instrumenting test package. -->
+ <instrumentation
+ android:name="android.support.test.runner.AndroidJUnitRunner"
+ android:label="CTS preconditions test for 'content' module"
+ android:targetPackage="android.content.preconditions" >
+ </instrumentation>
+</manifest>
diff --git a/tests/tests/content/preconditions/src/android/content/preconditions/PreconditionsTest.java b/tests/tests/content/preconditions/src/android/content/preconditions/PreconditionsTest.java
new file mode 100644
index 0000000..d4b3b1d
--- /dev/null
+++ b/tests/tests/content/preconditions/src/android/content/preconditions/PreconditionsTest.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2015 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.content.preconditions;
+
+import android.test.AndroidTestCase;
+
+import com.android.compatibility.common.preconditions.WifiHelper;
+
+/**
+ * A test to verify that device-side preconditions are met for the content module of CTS
+ */
+public class PreconditionsTest extends AndroidTestCase {
+
+ /**
+ * Test if device is connected to WiFi
+ * @throws Exception
+ */
+ public void testWifiConnected() throws Exception {
+ assertTrue("Device must have active network connection",
+ WifiHelper.isWifiConnected(this.getContext()));
+ }
+
+}
diff --git a/tests/tests/net/AndroidTest.xml b/tests/tests/net/AndroidTest.xml
index 2ed7e3a..1736151 100644
--- a/tests/tests/net/AndroidTest.xml
+++ b/tests/tests/net/AndroidTest.xml
@@ -14,15 +14,13 @@
-->
<configuration description="Test module config for net apis">
<include name="common-config" />
+ <target_preparer class="com.android.compatibility.common.tradefed.targetprep.ApkPreconditionCheck">
+ <option name="apk" value="CtsNetPreconditions.apk"/>
+ <option name="package" value="android.net.preconditions"/>
+ </target_preparer>
<option name="apk-installer:test-file-name" value="CtsNetTestCases.apk" />
<test class="com.android.tradefed.testtype.InstrumentationTest" >
<option name="package" value="android.net.cts" />
<option name="runner" value="android.support.test.runner.AndroidJUnitRunner" />
</test>
-
- <target_preparer class="com.android.compatibility.common.tradefed.targetprep.ApkPreconditionCheck">
- <option name="apk" value="CtsNetPreconditions.apk"/>
- <option name="package" value="android.net.preconditions"/>
- </target_preparer>
-
</configuration>
diff --git a/tests/tests/net/preconditions/src/android/net/preconditions/PreconditionsTest.java b/tests/tests/net/preconditions/src/android/net/preconditions/PreconditionsTest.java
index 3dc3745..4e132cb 100644
--- a/tests/tests/net/preconditions/src/android/net/preconditions/PreconditionsTest.java
+++ b/tests/tests/net/preconditions/src/android/net/preconditions/PreconditionsTest.java
@@ -15,9 +15,6 @@
*/
package android.net.preconditions;
-import android.content.Context;
-import android.net.ConnectivityManager;
-import android.net.NetworkInfo;
import android.test.AndroidTestCase;
import com.android.compatibility.common.preconditions.WifiHelper;
diff --git a/tests/tests/text/Android.mk b/tests/tests/text/Android.mk
index 8e80da8..eb8e7ea 100644
--- a/tests/tests/text/Android.mk
+++ b/tests/tests/text/Android.mk
@@ -36,3 +36,5 @@
#LOCAL_SDK_VERSION := current
include $(BUILD_CTS_PACKAGE)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/tests/tests/text/AndroidManifest.xml b/tests/tests/text/AndroidManifest.xml
index 5607fac..864f655 100644
--- a/tests/tests/text/AndroidManifest.xml
+++ b/tests/tests/text/AndroidManifest.xml
@@ -74,4 +74,3 @@
</instrumentation>
</manifest>
-
diff --git a/tests/tests/text/AndroidTest.xml b/tests/tests/text/AndroidTest.xml
index 922bce2..01d1808 100644
--- a/tests/tests/text/AndroidTest.xml
+++ b/tests/tests/text/AndroidTest.xml
@@ -15,6 +15,10 @@
-->
<configuration description="Configuration for Text Tests">
<include name="common-config" />
+ <target_preparer class="com.android.compatibility.common.tradefed.targetprep.ApkPreconditionCheck">
+ <option name="apk" value="CtsTextPreconditions.apk"/>
+ <option name="package" value="android.text.preconditions"/>
+ </target_preparer>
<option name="apk-installer:test-file-name" value="CtsTextTestCases.apk" />
<test class="com.android.tradefed.testtype.InstrumentationTest" >
<option name="package" value="android.text.cts" />
diff --git a/tests/tests/text/preconditions/Android.mk b/tests/tests/text/preconditions/Android.mk
new file mode 100644
index 0000000..c91de75
--- /dev/null
+++ b/tests/tests/text/preconditions/Android.mk
@@ -0,0 +1,39 @@
+# Copyright (C) 2015 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_DEX_PREOPT := false
+
+LOCAL_PROGUARD_ENABLED := disabled
+
+LOCAL_STATIC_JAVA_LIBRARIES := android-support-test compatibility-device-preconditions
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+LOCAL_PACKAGE_NAME := CtsTextPreconditions
+
+# Tag this module as a cts_v2 test artifact
+LOCAL_COMPATIBILITY_SUITE := cts_v2
+
+LOCAL_SDK_VERSION := current
+
+include $(BUILD_PACKAGE)
diff --git a/tests/tests/text/preconditions/AndroidManifest.xml b/tests/tests/text/preconditions/AndroidManifest.xml
new file mode 100644
index 0000000..d5dbbed
--- /dev/null
+++ b/tests/tests/text/preconditions/AndroidManifest.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2015 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="android.text.preconditions">
+ <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
+ <application>
+ <uses-library android:name="android.test.runner" />
+ </application>
+
+ <!-- self-instrumenting test package. -->
+ <instrumentation
+ android:name="android.support.test.runner.AndroidJUnitRunner"
+ android:label="CTS preconditions test for 'text' module"
+ android:targetPackage="android.text.preconditions" >
+ </instrumentation>
+</manifest>
diff --git a/tests/tests/text/preconditions/src/android/text/preconditions/PreconditionsTest.java b/tests/tests/text/preconditions/src/android/text/preconditions/PreconditionsTest.java
new file mode 100644
index 0000000..41ab70b
--- /dev/null
+++ b/tests/tests/text/preconditions/src/android/text/preconditions/PreconditionsTest.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2015 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.text.preconditions;
+
+import android.test.AndroidTestCase;
+
+import com.android.compatibility.common.preconditions.WifiHelper;
+
+/**
+ * A test to verify that device-side preconditions are met for the text module of CTS
+ */
+public class PreconditionsTest extends AndroidTestCase {
+
+ /**
+ * Test if device is connected to WiFi
+ * @throws Exception
+ */
+ public void testWifiConnected() throws Exception {
+ assertTrue("Device must have active network connection",
+ WifiHelper.isWifiConnected(this.getContext()));
+ }
+
+}
diff --git a/tests/tests/webkit/Android.mk b/tests/tests/webkit/Android.mk
index 85377ae..3d6cbde 100644
--- a/tests/tests/webkit/Android.mk
+++ b/tests/tests/webkit/Android.mk
@@ -36,3 +36,5 @@
#LOCAL_SDK_VERSION := current
include $(BUILD_CTS_PACKAGE)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/tests/tests/webkit/AndroidTest.xml b/tests/tests/webkit/AndroidTest.xml
index 53d44fc..bfbabe3 100644
--- a/tests/tests/webkit/AndroidTest.xml
+++ b/tests/tests/webkit/AndroidTest.xml
@@ -15,6 +15,10 @@
-->
<configuration description="Configuration for Webkit Tests">
<include name="common-config" />
+ <target_preparer class="com.android.compatibility.common.tradefed.targetprep.ApkPreconditionCheck">
+ <option name="apk" value="CtsWebkitPreconditions.apk"/>
+ <option name="package" value="android.webkit.preconditions"/>
+ </target_preparer>
<option name="apk-installer:test-file-name" value="CtsWebkitTestCases.apk" />
<test class="com.android.tradefed.testtype.InstrumentationTest" >
<option name="package" value="android.webkit.cts" />
diff --git a/tests/tests/webkit/preconditions/Android.mk b/tests/tests/webkit/preconditions/Android.mk
new file mode 100644
index 0000000..0709b2d
--- /dev/null
+++ b/tests/tests/webkit/preconditions/Android.mk
@@ -0,0 +1,39 @@
+# Copyright (C) 2015 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_DEX_PREOPT := false
+
+LOCAL_PROGUARD_ENABLED := disabled
+
+LOCAL_STATIC_JAVA_LIBRARIES := android-support-test compatibility-device-preconditions
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+LOCAL_PACKAGE_NAME := CtsWebkitPreconditions
+
+# Tag this module as a cts_v2 test artifact
+LOCAL_COMPATIBILITY_SUITE := cts_v2
+
+LOCAL_SDK_VERSION := current
+
+include $(BUILD_PACKAGE)
diff --git a/tests/tests/webkit/preconditions/AndroidManifest.xml b/tests/tests/webkit/preconditions/AndroidManifest.xml
new file mode 100644
index 0000000..a987975
--- /dev/null
+++ b/tests/tests/webkit/preconditions/AndroidManifest.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2015 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="android.webkit.preconditions">
+ <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
+ <application>
+ <uses-library android:name="android.test.runner" />
+ </application>
+
+ <!-- self-instrumenting test package. -->
+ <instrumentation
+ android:name="android.support.test.runner.AndroidJUnitRunner"
+ android:label="CTS preconditions test for 'webkit' module"
+ android:targetPackage="android.webkit.preconditions" >
+ </instrumentation>
+</manifest>
diff --git a/tests/tests/webkit/preconditions/src/android/webkit/preconditions/PreconditionsTest.java b/tests/tests/webkit/preconditions/src/android/webkit/preconditions/PreconditionsTest.java
new file mode 100644
index 0000000..6a4e0e2
--- /dev/null
+++ b/tests/tests/webkit/preconditions/src/android/webkit/preconditions/PreconditionsTest.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2015 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.webkit.preconditions;
+
+import android.test.AndroidTestCase;
+
+import com.android.compatibility.common.preconditions.WifiHelper;
+
+/**
+ * A test to verify that device-side preconditions are met for the webkit module of CTS
+ */
+public class PreconditionsTest extends AndroidTestCase {
+
+ /**
+ * Test if device is connected to WiFi
+ * @throws Exception
+ */
+ public void testWifiConnected() throws Exception {
+ assertTrue("Device must have active network connection",
+ WifiHelper.isWifiConnected(this.getContext()));
+ }
+
+}
diff --git a/tests/tests/widget/Android.mk b/tests/tests/widget/Android.mk
index 888c0e6..47fd0be 100644
--- a/tests/tests/widget/Android.mk
+++ b/tests/tests/widget/Android.mk
@@ -33,3 +33,5 @@
LOCAL_COMPATIBILITY_SUITE := cts_v2
include $(BUILD_CTS_PACKAGE)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/tests/tests/widget/AndroidTest.xml b/tests/tests/widget/AndroidTest.xml
index 0ea8f1c..29a98bd 100644
--- a/tests/tests/widget/AndroidTest.xml
+++ b/tests/tests/widget/AndroidTest.xml
@@ -15,6 +15,10 @@
-->
<configuration description="Configuration for Widget Tests">
<include name="common-config" />
+ <target_preparer class="com.android.compatibility.common.tradefed.targetprep.ApkPreconditionCheck">
+ <option name="apk" value="CtsWidgetPreconditions.apk"/>
+ <option name="package" value="android.widget.preconditions"/>
+ </target_preparer>
<option name="apk-installer:test-file-name" value="CtsWidgetTestCases.apk" />
<test class="com.android.tradefed.testtype.InstrumentationTest" >
<option name="package" value="android.widget.cts" />
diff --git a/tests/tests/widget/preconditions/Android.mk b/tests/tests/widget/preconditions/Android.mk
new file mode 100644
index 0000000..7fe5744
--- /dev/null
+++ b/tests/tests/widget/preconditions/Android.mk
@@ -0,0 +1,39 @@
+# Copyright (C) 2015 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_DEX_PREOPT := false
+
+LOCAL_PROGUARD_ENABLED := disabled
+
+LOCAL_STATIC_JAVA_LIBRARIES := android-support-test compatibility-device-preconditions
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+LOCAL_PACKAGE_NAME := CtsWidgetPreconditions
+
+# Tag this module as a cts_v2 test artifact
+LOCAL_COMPATIBILITY_SUITE := cts_v2
+
+LOCAL_SDK_VERSION := current
+
+include $(BUILD_PACKAGE)
diff --git a/tests/tests/widget/preconditions/AndroidManifest.xml b/tests/tests/widget/preconditions/AndroidManifest.xml
new file mode 100644
index 0000000..fd6c512
--- /dev/null
+++ b/tests/tests/widget/preconditions/AndroidManifest.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2015 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="android.widget.preconditions">
+ <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
+ <application>
+ <uses-library android:name="android.test.runner" />
+ </application>
+
+ <!-- self-instrumenting test package. -->
+ <instrumentation
+ android:name="android.support.test.runner.AndroidJUnitRunner"
+ android:label="CTS preconditions test for 'widget' module"
+ android:targetPackage="android.widget.preconditions" >
+ </instrumentation>
+</manifest>
diff --git a/tests/tests/widget/preconditions/src/android/widget/preconditions/PreconditionsTest.java b/tests/tests/widget/preconditions/src/android/widget/preconditions/PreconditionsTest.java
new file mode 100644
index 0000000..945ea46
--- /dev/null
+++ b/tests/tests/widget/preconditions/src/android/widget/preconditions/PreconditionsTest.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2015 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.widget.preconditions;
+
+import android.test.AndroidTestCase;
+
+import com.android.compatibility.common.preconditions.WifiHelper;
+
+/**
+ * A test to verify that device-side preconditions are met for the widget module of CTS
+ */
+public class PreconditionsTest extends AndroidTestCase {
+
+ /**
+ * Test if device is connected to WiFi
+ * @throws Exception
+ */
+ public void testWifiConnected() throws Exception {
+ assertTrue("Device must have active network connection",
+ WifiHelper.isWifiConnected(this.getContext()));
+ }
+
+}