DO NOT MERGE: Add SmsTest and mege emulator smoke tests
Picked Changes: Add SMS test to verify emulator can receive sms from DDMS Adding test tag to sms test Add up to 6 10 second delays to wait for sms Merging emulator smoke test projects Combining SmsTest, GpsLocationTests, and ConnectivityTest Conflicts: build/sdk.atree Change-Id: I1343c59418a69b2f5e1eb0c6cde54f2bc09300ac
This commit is contained in:
@@ -380,6 +380,5 @@ development/samples/Support7Demos
|
|||||||
# Tests Component
|
# Tests Component
|
||||||
##############################################################################
|
##############################################################################
|
||||||
framework/layoutlib-tests.jar tests/libtests/layoutlib-tests.jar
|
framework/layoutlib-tests.jar tests/libtests/layoutlib-tests.jar
|
||||||
system/app/ConnectivityTest.apk tests/emulator-test-apps/ConnectivityTest.apk
|
system/app/EmulatorSmokeTests.apk tests/emulator-test-apps/EmulatorSmokeTests.apk
|
||||||
system/app/GpsLocationTest.apk tests/emulator-test-apps/GpsLocationTest.apk
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,32 +0,0 @@
|
|||||||
# Copyright (C) 2011 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)
|
|
||||||
|
|
||||||
LOCAL_MODULE_TAGS := optional
|
|
||||||
|
|
||||||
# Only compile source java files in this apk.
|
|
||||||
LOCAL_SRC_FILES := $(call all-java-files-under, src)
|
|
||||||
|
|
||||||
LOCAL_PACKAGE_NAME := ConnectivityTest
|
|
||||||
|
|
||||||
LOCAL_SDK_VERSION := 4
|
|
||||||
|
|
||||||
LOCAL_PROGUARD_ENABLED := disabled
|
|
||||||
|
|
||||||
include $(BUILD_PACKAGE)
|
|
||||||
|
|
||||||
# Use the following include to make our test apk.
|
|
||||||
include $(call all-makefiles-under,$(LOCAL_PATH))
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!-- Copyright (C) 2011 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.emulator.gps.test"
|
|
||||||
android:versionCode="1"
|
|
||||||
android:versionName="1.0">
|
|
||||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
|
||||||
<uses-sdk android:minSdkVersion="4" />
|
|
||||||
<instrumentation android:targetPackage="com.android.emulator.gps.test"
|
|
||||||
android:name="android.test.InstrumentationTestRunner" />
|
|
||||||
<application android:label="GPS Location Test">
|
|
||||||
<uses-library android:name="android.test.runner" />
|
|
||||||
</application>
|
|
||||||
</manifest>
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
# Copyright (C) 2011 The Android Open Source Project
|
# Copyright (C) 2014 The Android Open Source Project
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
@@ -15,18 +15,18 @@
|
|||||||
LOCAL_PATH:= $(call my-dir)
|
LOCAL_PATH:= $(call my-dir)
|
||||||
include $(CLEAR_VARS)
|
include $(CLEAR_VARS)
|
||||||
|
|
||||||
|
LOCAL_STATIC_JAVA_LIBRARIES := android-test-lib
|
||||||
|
|
||||||
LOCAL_MODULE_TAGS := optional
|
LOCAL_MODULE_TAGS := optional
|
||||||
|
|
||||||
# Only compile source java files in this apk.
|
# Only compile source java files in this apk.
|
||||||
LOCAL_SRC_FILES := $(call all-java-files-under, src)
|
LOCAL_SRC_FILES := $(call all-java-files-under, src)
|
||||||
|
|
||||||
LOCAL_PACKAGE_NAME := GpsLocationTest
|
LOCAL_PACKAGE_NAME := EmulatorSmokeTests
|
||||||
|
|
||||||
LOCAL_SDK_VERSION := 4
|
LOCAL_SDK_VERSION := 4
|
||||||
|
|
||||||
LOCAL_PROGUARD_ENABLED := disabled
|
LOCAL_PROGUARD_ENABLED := disabled
|
||||||
|
|
||||||
include $(BUILD_PACKAGE)
|
|
||||||
|
|
||||||
# Use the following include to make our test apk.
|
include $(BUILD_PACKAGE)
|
||||||
include $(call all-makefiles-under,$(LOCAL_PATH))
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<!-- Copyright (C) 2011 The Android Open Source Project
|
<!-- Copyright (C) 2014 The Android Open Source Project
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@@ -14,14 +14,15 @@
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
-->
|
-->
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="com.android.emulator.connectivity.test"
|
package="com.android.emulator.smoketests">
|
||||||
android:versionCode="1"
|
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||||
android:versionName="1.0">
|
|
||||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
|
<uses-permission android:name="android.permission.READ_SMS" />
|
||||||
<uses-sdk android:minSdkVersion="4" />
|
<uses-sdk android:minSdkVersion="4" />
|
||||||
<instrumentation android:targetPackage="com.android.emulator.connectivity.test" android:name="android.test.InstrumentationTestRunner" />
|
<instrumentation android:targetPackage="com.android.emulator.smoketests"
|
||||||
<application android:label="Connectivity Test">
|
android:name="android.support.test.runner.AndroidJUnitRunner" />
|
||||||
<uses-library android:name="android.test.runner" />
|
<application android:label="Emulator Smoke Tests">
|
||||||
</application>
|
</application>
|
||||||
</manifest>
|
</manifest>
|
||||||
|
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.android.emulator.connectivity.test;
|
package com.android.emulator.smoketests.connectivity;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.android.emulator.gps.test;
|
package com.android.emulator.smoketests.gps;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.location.Location;
|
import android.location.Location;
|
||||||
@@ -0,0 +1,85 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2014 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.emulator.smoketests.sms;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.ContentResolver;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.database.Cursor;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.HandlerThread;
|
||||||
|
import com.android.test.InjectContext;
|
||||||
|
|
||||||
|
import org.junit.Assert;
|
||||||
|
import static junit.framework.Assert.assertEquals;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
/**
|
||||||
|
* Sms Test
|
||||||
|
*
|
||||||
|
* Test that an SMS message has been received
|
||||||
|
*/
|
||||||
|
public class SmsTest {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prior to running this test an sms must be sent
|
||||||
|
* via DDMS
|
||||||
|
*/
|
||||||
|
public final static String NUMBER = "5551212";
|
||||||
|
public final static String BODY = "test sms";
|
||||||
|
private final static int SMS_POLL_TIME_MS = 10 * 1000;
|
||||||
|
private final static int SIXY_SECONDS_OF_LOOPS = 6;
|
||||||
|
@InjectContext
|
||||||
|
public Context mContext;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verify that an SMS has been received with the correct number and body
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testReceivedSms() throws java.lang.InterruptedException {
|
||||||
|
Cursor c = getSmsCursor();
|
||||||
|
c.moveToFirst();
|
||||||
|
|
||||||
|
String number = c.getString(c.getColumnIndexOrThrow("address"));
|
||||||
|
String body = c.getString(c.getColumnIndexOrThrow("body"));
|
||||||
|
|
||||||
|
c.close();
|
||||||
|
|
||||||
|
assertEquals(NUMBER, number);
|
||||||
|
assertEquals(BODY, body);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Cursor getSmsCursor() throws java.lang.InterruptedException {
|
||||||
|
ContentResolver r = mContext.getContentResolver();
|
||||||
|
Uri message = Uri.parse("content://sms/");
|
||||||
|
Cursor c;
|
||||||
|
|
||||||
|
for(int i = 0; i < SIXY_SECONDS_OF_LOOPS; i++) {
|
||||||
|
c = r.query(message,null,null,null,null);
|
||||||
|
|
||||||
|
if(c.getCount() != 0) {
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
c.close();
|
||||||
|
Thread.sleep(SMS_POLL_TIME_MS);
|
||||||
|
}
|
||||||
|
Assert.fail("Did not find any SMS messages. Giving up");
|
||||||
|
// necessary for compilation
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user