upload android base code part4
This commit is contained in:
parent
b9e30e05b1
commit
78ea2404cd
23455 changed files with 5250148 additions and 0 deletions
42
android/cts/tools/cts-preconditions/Android.mk
Normal file
42
android/cts/tools/cts-preconditions/Android.mk
Normal file
|
@ -0,0 +1,42 @@
|
|||
# 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 := tests
|
||||
# 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 \
|
||||
legacy-android-test
|
||||
|
||||
LOCAL_SRC_FILES := $(call all-java-files-under, src)
|
||||
|
||||
# Tag this module as a cts test artifact
|
||||
LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
|
||||
|
||||
LOCAL_PACKAGE_NAME := CtsPreconditions
|
||||
|
||||
LOCAL_SDK_VERSION := current
|
||||
|
||||
include $(BUILD_PACKAGE)
|
31
android/cts/tools/cts-preconditions/AndroidManifest.xml
Normal file
31
android/cts/tools/cts-preconditions/AndroidManifest.xml
Normal file
|
@ -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="com.android.preconditions.cts">
|
||||
<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"
|
||||
android:targetPackage="com.android.preconditions.cts" >
|
||||
</instrumentation>
|
||||
</manifest>
|
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
* 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 com.android.preconditions.cts;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.test.AndroidTestCase;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.compatibility.common.preconditions.ExternalStorageHelper;
|
||||
import com.android.compatibility.common.preconditions.ScreenLockHelper;
|
||||
|
||||
/**
|
||||
* A test to verify that device-side preconditions are met for CTS
|
||||
*/
|
||||
public class PreconditionsTest extends AndroidTestCase {
|
||||
|
||||
private static final String TAG = "PreconditionsTest";
|
||||
|
||||
/**
|
||||
* Test if device has no screen lock
|
||||
* @throws Exception
|
||||
*/
|
||||
public void testScreenUnlocked() throws Exception {
|
||||
PackageManager pm = this.getContext().getPackageManager();
|
||||
if (pm.hasSystemFeature(PackageManager.FEATURE_LEANBACK)
|
||||
|| pm.hasSystemFeature(PackageManager.FEATURE_WATCH)
|
||||
|| pm.hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE)) {
|
||||
Log.i(TAG, "Skipping screen lock precondition for this device type");
|
||||
return; // do not test for unlocked screen on devices with no screen lock
|
||||
}
|
||||
assertFalse("Device must have screen lock disabled",
|
||||
ScreenLockHelper.isDeviceSecure(this.getContext()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if device has accessible external storage
|
||||
* @throws Exception
|
||||
*/
|
||||
public void testExternalStoragePresent() throws Exception {
|
||||
assertTrue("Device must have external storage mounted in order to run CTS",
|
||||
ExternalStorageHelper.isExternalStorageReadable());
|
||||
assertTrue("Device external storage must be writable in order to run CTS",
|
||||
ExternalStorageHelper.isExternalStorageWritable());
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue