Merge commit 'dbecc90220e924fc8c693dd903679e0e9d562820' into kraken * commit 'dbecc90220e924fc8c693dd903679e0e9d562820': Remove FrameworkTest package.
This commit is contained in:
@@ -50,6 +50,8 @@ $(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/framew
|
|||||||
$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/framework_intermediates/src/core/java/com/android/internal/backup)
|
$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/framework_intermediates/src/core/java/com/android/internal/backup)
|
||||||
$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/framework_intermediates/src/core/java/android/app)
|
$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/framework_intermediates/src/core/java/android/app)
|
||||||
$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/framework_intermediates/src/core/java/android/content)
|
$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/framework_intermediates/src/core/java/android/content)
|
||||||
|
$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/FrameworkTest_intermediates/)
|
||||||
|
|
||||||
|
|
||||||
# ************************************************
|
# ************************************************
|
||||||
# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
|
# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
|
||||||
|
|||||||
@@ -1,15 +0,0 @@
|
|||||||
LOCAL_PATH:= $(call my-dir)
|
|
||||||
include $(CLEAR_VARS)
|
|
||||||
|
|
||||||
LOCAL_MODULE_TAGS := tests
|
|
||||||
|
|
||||||
# Only compile source java files in this apk.
|
|
||||||
LOCAL_SRC_FILES := $(call all-java-files-under, src)
|
|
||||||
|
|
||||||
LOCAL_JAVA_LIBRARIES := android.test.runner
|
|
||||||
|
|
||||||
LOCAL_PACKAGE_NAME := FrameworkTest
|
|
||||||
|
|
||||||
include $(BUILD_PACKAGE)
|
|
||||||
# Use the following include to make our test apk.
|
|
||||||
include $(call all-makefiles-under,$(LOCAL_PATH))
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!-- Copyright (C) 2008 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.frameworktest">
|
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.READ_CONTACTS" />
|
|
||||||
<uses-permission android:name="android.permission.HARDWARE_TEST" />
|
|
||||||
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
|
|
||||||
<uses-permission android:name="android.permission.ACCESSIBILITY_EVENT_VIEW_TYPES" />
|
|
||||||
<uses-permission android:name="android.permission.ACCESSIBILITY_EVENT_TRANSITION_TYPES" />
|
|
||||||
<uses-permission android:name="android.permission.ACCESSIBILITY_EVENT_NOTIFICATION_TYPES" />
|
|
||||||
|
|
||||||
<application android:theme="@style/Theme">
|
|
||||||
<uses-library android:name="android.test.runner" />
|
|
||||||
|
|
||||||
<activity android:name=".FrameworkTestApplication" android:label="FrameworkTestApplication">
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.MAIN" />
|
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
|
||||||
</intent-filter>
|
|
||||||
</activity>
|
|
||||||
|
|
||||||
<activity android:name=".performance.InvalidateCycle" android:label="InvalidateCycle">
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.MAIN" />
|
|
||||||
<category android:name="android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST" />
|
|
||||||
</intent-filter>
|
|
||||||
</activity>
|
|
||||||
|
|
||||||
<activity android:name=".settings.RingtonePickerActivityLauncher" android:label="RingtonePickerActivityLauncher">
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.MAIN" />
|
|
||||||
<category android:name="android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST" />
|
|
||||||
</intent-filter>
|
|
||||||
</activity>
|
|
||||||
|
|
||||||
|
|
||||||
</application>
|
|
||||||
|
|
||||||
</manifest>
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
FrameworkTestApplication should hold snippets of functionality that are
|
|
||||||
helpful for testing the UI framework code, but not appropriate for
|
|
||||||
sample code. For instance, a layout contrived to exercise an edge case
|
|
||||||
of scrolling behavior.
|
|
||||||
|
|
||||||
InstrumentationTestCases should be added under tests and added to the
|
|
||||||
list of tests in FrameworkInstrumentationTestRunner.
|
|
||||||
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
|
|
||||||
<resources>
|
|
||||||
<style name="Theme" parent="android:Theme">
|
|
||||||
<item name="android:windowAnimationStyle">@style/Animation</item>
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<style name="Animation">
|
|
||||||
<item name="android:activityOpenEnterAnimation">@null</item>
|
|
||||||
<item name="android:activityOpenExitAnimation">@null</item>
|
|
||||||
<item name="android:activityCloseEnterAnimation">@null</item>
|
|
||||||
<item name="android:activityCloseExitAnimation">@null</item>
|
|
||||||
<item name="android:taskOpenEnterAnimation">@null</item>
|
|
||||||
<item name="android:taskOpenExitAnimation">@null</item>
|
|
||||||
<item name="android:taskCloseEnterAnimation">@null</item>
|
|
||||||
<item name="android:taskCloseExitAnimation">@null</item>
|
|
||||||
<item name="android:taskToFrontEnterAnimation">@null</item>
|
|
||||||
<item name="android:taskToFrontExitAnimation">@null</item>
|
|
||||||
<item name="android:taskToBackEnterAnimation">@null</item>
|
|
||||||
<item name="android:taskToBackExitAnimation">@null</item>
|
|
||||||
</style>
|
|
||||||
</resources>
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2007 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.frameworktest;
|
|
||||||
|
|
||||||
import android.app.LauncherActivity;
|
|
||||||
import android.content.Intent;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Holds little snippets of functionality used as code under test for
|
|
||||||
* instrumentation tests of framework code.
|
|
||||||
*/
|
|
||||||
public class FrameworkTestApplication extends LauncherActivity {
|
|
||||||
|
|
||||||
protected Intent getTargetIntent() {
|
|
||||||
// TODO: partition into categories by label like the sample code app
|
|
||||||
Intent targetIntent = new Intent(Intent.ACTION_MAIN, null);
|
|
||||||
targetIntent.addCategory(Intent.CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST);
|
|
||||||
targetIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
||||||
return targetIntent;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,65 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2008 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.frameworktest.performance;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.os.Debug;
|
|
||||||
import android.os.Handler;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.graphics.Canvas;
|
|
||||||
|
|
||||||
public class InvalidateCycle extends Activity {
|
|
||||||
private boolean mStartProfiling;
|
|
||||||
private InvalidateCycle.AutoInvalidateView mView;
|
|
||||||
|
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
|
|
||||||
mView = new AutoInvalidateView(this);
|
|
||||||
mView.setLayoutParams(new ViewGroup.LayoutParams(16, 16));
|
|
||||||
setContentView(mView);
|
|
||||||
|
|
||||||
new Handler().postDelayed(new Runnable() {
|
|
||||||
public void run() {
|
|
||||||
mStartProfiling = true;
|
|
||||||
android.util.Log.d("Performance", "Profiling started");
|
|
||||||
Debug.startMethodTracing("invalidateCycle");
|
|
||||||
mView.invalidate();
|
|
||||||
}
|
|
||||||
}, 15000);
|
|
||||||
}
|
|
||||||
|
|
||||||
private class AutoInvalidateView extends View {
|
|
||||||
private boolean mFirstDraw;
|
|
||||||
|
|
||||||
public AutoInvalidateView(Context context) {
|
|
||||||
super(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void onDraw(Canvas canvas) {
|
|
||||||
if (mStartProfiling && !mFirstDraw) {
|
|
||||||
Debug.stopMethodTracing();
|
|
||||||
android.util.Log.d("Performance", "Profiling ended");
|
|
||||||
mFirstDraw = true;
|
|
||||||
}
|
|
||||||
canvas.drawColor(0xFFFF0000);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,79 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2007 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.frameworktest.settings;
|
|
||||||
|
|
||||||
import com.android.internal.app.RingtonePickerActivity;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.media.RingtoneManager;
|
|
||||||
import android.net.Uri;
|
|
||||||
import android.os.Bundle;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Activity that will launch the RingtonePickerActivity as a subactivity, and
|
|
||||||
* waits for its result.
|
|
||||||
*/
|
|
||||||
public class RingtonePickerActivityLauncher extends Activity {
|
|
||||||
|
|
||||||
private static final String TAG = "RingtonePickerActivityLauncher";
|
|
||||||
|
|
||||||
public boolean resultReceived = false;
|
|
||||||
|
|
||||||
public int resultCode;
|
|
||||||
public Intent result;
|
|
||||||
|
|
||||||
public Uri pickedUri;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
|
|
||||||
setContentView(android.R.layout.simple_list_item_1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Launches the {@link RingtonePickerActivity} and blocks until it returns.
|
|
||||||
*
|
|
||||||
* @param showDefault {@link RingtonePickerActivity#EXTRA_SHOW_DEFAULT}
|
|
||||||
* @param existingUri {@link RingtonePickerActivity#EXTRA_EXISTING_URI}
|
|
||||||
* @param filterColumns {@link RingtonePickerActivity#EXTRA_RINGTONE_COLUMNS}
|
|
||||||
*/
|
|
||||||
public void launchRingtonePickerActivity(boolean showDefault, Uri existingUri,
|
|
||||||
int types) {
|
|
||||||
Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
|
|
||||||
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, showDefault);
|
|
||||||
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, existingUri);
|
|
||||||
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, types);
|
|
||||||
startActivityForResult(intent, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
||||||
super.onActivityResult(requestCode, resultCode, data);
|
|
||||||
|
|
||||||
resultReceived = true;
|
|
||||||
|
|
||||||
this.resultCode = resultCode;
|
|
||||||
this.result = data;
|
|
||||||
|
|
||||||
if (data != null) {
|
|
||||||
this.pickedUri = data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
LOCAL_PATH:= $(call my-dir)
|
|
||||||
include $(CLEAR_VARS)
|
|
||||||
|
|
||||||
# We only want this apk build for tests.
|
|
||||||
LOCAL_MODULE_TAGS := tests
|
|
||||||
|
|
||||||
# Include all test java files.
|
|
||||||
LOCAL_SRC_FILES := $(call all-subdir-java-files)
|
|
||||||
|
|
||||||
LOCAL_JAVA_LIBRARIES := android.test.runner
|
|
||||||
|
|
||||||
LOCAL_PACKAGE_NAME := FrameworkTestTests
|
|
||||||
|
|
||||||
LOCAL_INSTRUMENTATION_FOR := FrameworkTest
|
|
||||||
|
|
||||||
include $(BUILD_PACKAGE)
|
|
||||||
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!-- Copyright (C) 2007 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 name must be unique so suffix with "tests" so package loader doesn't ignore us -->
|
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
package="com.android.frameworktest.tests">
|
|
||||||
|
|
||||||
<application>
|
|
||||||
<uses-library android:name="android.test.runner" />
|
|
||||||
</application>
|
|
||||||
|
|
||||||
<!--
|
|
||||||
This declares that this app uses the instrumentation test runner targeting
|
|
||||||
the package of com.android.frameworktest. To run the tests use the command:
|
|
||||||
"adb shell am instrument -w com.android.frameworktest.tests/android.test.InstrumentationTestRunner"
|
|
||||||
-->
|
|
||||||
<instrumentation android:name="android.test.InstrumentationTestRunner"
|
|
||||||
android:targetPackage="com.android.frameworktest"
|
|
||||||
android:label="framework tests"/>
|
|
||||||
|
|
||||||
</manifest>
|
|
||||||
@@ -1,227 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2007 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.frameworktest.settings;
|
|
||||||
|
|
||||||
import com.android.frameworktest.settings.RingtonePickerActivityLauncher;
|
|
||||||
|
|
||||||
import android.app.Instrumentation;
|
|
||||||
import android.database.Cursor;
|
|
||||||
import android.media.RingtoneManager;
|
|
||||||
import android.net.Uri;
|
|
||||||
import android.provider.MediaStore;
|
|
||||||
import android.test.ActivityInstrumentationTestCase;
|
|
||||||
import android.test.suitebuilder.annotation.Suppress;
|
|
||||||
import android.view.KeyEvent;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests the RingtonePickerActivity.
|
|
||||||
* <p>
|
|
||||||
* There is a launcher for launching the RingtonePickerActivity (RPA) since the RPA needs
|
|
||||||
* to be a subactivity. We don't have a reference to the actual RPA.
|
|
||||||
* <p>
|
|
||||||
* This relies heavily on keypresses getting to the right widget. It depends on:
|
|
||||||
* <li> Less than NUM_RINGTONES_AND_SOME ringtones on the system
|
|
||||||
* <li> Pressing arrow-down a ton will eventually end up on the 'Cancel' button
|
|
||||||
* <li> From the 'Cancel' button, pressing arrow-left will end up on 'OK' button
|
|
||||||
*/
|
|
||||||
@Suppress
|
|
||||||
public class RingtonePickerActivityTest extends ActivityInstrumentationTestCase<RingtonePickerActivityLauncher> {
|
|
||||||
|
|
||||||
private static final int NUM_RINGTONES_AND_SOME = 20;
|
|
||||||
private RingtonePickerActivityLauncher mActivity;
|
|
||||||
private Instrumentation mInstrumentation;
|
|
||||||
|
|
||||||
public RingtonePickerActivityTest() {
|
|
||||||
super("com.android.frameworktest", RingtonePickerActivityLauncher.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void setUp() throws Exception {
|
|
||||||
super.setUp();
|
|
||||||
|
|
||||||
mActivity = getActivity();
|
|
||||||
mInstrumentation = getInstrumentation();
|
|
||||||
assertNotNull(mActivity);
|
|
||||||
assertFalse(mActivity.resultReceived);
|
|
||||||
assertNotNull(mInstrumentation);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testDefault() {
|
|
||||||
mActivity.launchRingtonePickerActivity(true, null, RingtoneManager.TYPE_ALL);
|
|
||||||
mInstrumentation.waitForIdleSync();
|
|
||||||
|
|
||||||
// Go to top
|
|
||||||
goTo(true);
|
|
||||||
// Select default ringtone
|
|
||||||
sendKeys(KeyEvent.KEYCODE_DPAD_CENTER);
|
|
||||||
// Go to bottom/cancel button
|
|
||||||
goTo(false);
|
|
||||||
// Select OK button
|
|
||||||
sendKeys(KeyEvent.KEYCODE_DPAD_LEFT, KeyEvent.KEYCODE_DPAD_CENTER);
|
|
||||||
|
|
||||||
mInstrumentation.waitForIdleSync();
|
|
||||||
|
|
||||||
assertTrue(mActivity.resultReceived);
|
|
||||||
assertNotNull(mActivity.result);
|
|
||||||
assertTrue(RingtoneManager.isDefault(mActivity.pickedUri));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testFirst() {
|
|
||||||
mActivity.launchRingtonePickerActivity(true, null, RingtoneManager.TYPE_ALL);
|
|
||||||
mInstrumentation.waitForIdleSync();
|
|
||||||
|
|
||||||
// Go to top
|
|
||||||
goTo(true);
|
|
||||||
// Select first (non-default) ringtone
|
|
||||||
sendKeys(KeyEvent.KEYCODE_DPAD_DOWN, KeyEvent.KEYCODE_DPAD_CENTER);
|
|
||||||
// Go to bottom/cancel button
|
|
||||||
goTo(false);
|
|
||||||
// Select OK button
|
|
||||||
sendKeys(KeyEvent.KEYCODE_DPAD_LEFT, KeyEvent.KEYCODE_DPAD_CENTER);
|
|
||||||
|
|
||||||
mInstrumentation.waitForIdleSync();
|
|
||||||
|
|
||||||
assertTrue(mActivity.resultReceived);
|
|
||||||
assertNotNull(mActivity.result);
|
|
||||||
assertNotNull(mActivity.pickedUri);
|
|
||||||
assertFalse(RingtoneManager.isDefault(mActivity.pickedUri));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testExisting() {
|
|
||||||
// We need to get an existing ringtone first, so launch it, pick first,
|
|
||||||
// and keep that URI
|
|
||||||
testFirst();
|
|
||||||
Uri firstUri = mActivity.pickedUri;
|
|
||||||
|
|
||||||
mActivity.launchRingtonePickerActivity(true, firstUri, RingtoneManager.TYPE_ALL);
|
|
||||||
mInstrumentation.waitForIdleSync();
|
|
||||||
|
|
||||||
//// Hit cancel:
|
|
||||||
|
|
||||||
// Go to bottom
|
|
||||||
goTo(false);
|
|
||||||
// Select Cancel button
|
|
||||||
sendKeys(KeyEvent.KEYCODE_DPAD_CENTER);
|
|
||||||
|
|
||||||
mInstrumentation.waitForIdleSync();
|
|
||||||
|
|
||||||
assertTrue(mActivity.resultReceived);
|
|
||||||
assertEquals(mActivity.pickedUri, firstUri);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testExistingButDifferent() {
|
|
||||||
// We need to get an existing ringtone first, so launch it, pick first,
|
|
||||||
// and keep that URI
|
|
||||||
testFirst();
|
|
||||||
Uri firstUri = mActivity.pickedUri;
|
|
||||||
|
|
||||||
mActivity.launchRingtonePickerActivity(true, firstUri, RingtoneManager.TYPE_ALL);
|
|
||||||
mInstrumentation.waitForIdleSync();
|
|
||||||
|
|
||||||
//// Pick second:
|
|
||||||
|
|
||||||
// Go to top
|
|
||||||
goTo(true);
|
|
||||||
// Select second (non-default) ringtone
|
|
||||||
sendKeys(KeyEvent.KEYCODE_DPAD_DOWN, KeyEvent.KEYCODE_DPAD_DOWN,
|
|
||||||
KeyEvent.KEYCODE_DPAD_CENTER);
|
|
||||||
// Go to bottom/cancel button
|
|
||||||
goTo(false);
|
|
||||||
// Select OK button
|
|
||||||
sendKeys(KeyEvent.KEYCODE_DPAD_LEFT, KeyEvent.KEYCODE_DPAD_CENTER);
|
|
||||||
|
|
||||||
mInstrumentation.waitForIdleSync();
|
|
||||||
|
|
||||||
assertTrue(mActivity.resultReceived);
|
|
||||||
assertNotNull(mActivity.result);
|
|
||||||
assertTrue(!firstUri.equals(mActivity.pickedUri));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testCancel() {
|
|
||||||
mActivity.launchRingtonePickerActivity(true, null, RingtoneManager.TYPE_ALL);
|
|
||||||
mInstrumentation.waitForIdleSync();
|
|
||||||
|
|
||||||
// Go to bottom
|
|
||||||
goTo(false);
|
|
||||||
// Select Cancel button
|
|
||||||
sendKeys(KeyEvent.KEYCODE_DPAD_CENTER);
|
|
||||||
|
|
||||||
mInstrumentation.waitForIdleSync();
|
|
||||||
|
|
||||||
assertTrue(mActivity.resultReceived);
|
|
||||||
assertNull(mActivity.result);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testNoDefault() {
|
|
||||||
mActivity.launchRingtonePickerActivity(false, null, RingtoneManager.TYPE_ALL);
|
|
||||||
mInstrumentation.waitForIdleSync();
|
|
||||||
|
|
||||||
// Go to top
|
|
||||||
goTo(true);
|
|
||||||
// Select first (non-default) ringtone
|
|
||||||
sendKeys(KeyEvent.KEYCODE_DPAD_CENTER);
|
|
||||||
// Go to bottom/cancel button
|
|
||||||
goTo(false);
|
|
||||||
// Select OK button
|
|
||||||
sendKeys(KeyEvent.KEYCODE_DPAD_LEFT, KeyEvent.KEYCODE_DPAD_CENTER);
|
|
||||||
|
|
||||||
mInstrumentation.waitForIdleSync();
|
|
||||||
|
|
||||||
assertTrue(mActivity.resultReceived);
|
|
||||||
assertNotNull(mActivity.result);
|
|
||||||
assertNotNull(mActivity.pickedUri);
|
|
||||||
assertFalse(RingtoneManager.isDefault(mActivity.pickedUri));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testNotifications() {
|
|
||||||
mActivity.launchRingtonePickerActivity(false, null, RingtoneManager.TYPE_NOTIFICATION);
|
|
||||||
mInstrumentation.waitForIdleSync();
|
|
||||||
|
|
||||||
// Move to top of list
|
|
||||||
goTo(true);
|
|
||||||
// Select first ringtone in list
|
|
||||||
sendKeys(KeyEvent.KEYCODE_DPAD_CENTER);
|
|
||||||
// Move all the way down (will focus 'Cancel')
|
|
||||||
goTo(false);
|
|
||||||
// Move left and click (will click 'Ok')
|
|
||||||
sendKeys(KeyEvent.KEYCODE_DPAD_LEFT, KeyEvent.KEYCODE_DPAD_CENTER);
|
|
||||||
|
|
||||||
// Wait until main thread is idle
|
|
||||||
mInstrumentation.waitForIdleSync();
|
|
||||||
|
|
||||||
assertTrue(mActivity.resultReceived);
|
|
||||||
assertNotNull(mActivity.result);
|
|
||||||
assertNotNull(mActivity.pickedUri);
|
|
||||||
|
|
||||||
// Get the path of the picked ringtone
|
|
||||||
Uri uri = mActivity.pickedUri;
|
|
||||||
Cursor c = mActivity.getContentResolver().query(uri, new String[] { "_data" },
|
|
||||||
null, null, null);
|
|
||||||
assertTrue("Query for selected ringtone URI does not have a result", c.moveToFirst());
|
|
||||||
String path = c.getString(0);
|
|
||||||
// Quick check to see if the ringtone is a notification
|
|
||||||
assertTrue("The path of the selected ringtone did not contain \"notification\"",
|
|
||||||
path.contains("notifications"));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void goTo(boolean top) {
|
|
||||||
// Get to the buttons at the bottom (top == false), or the top (top == true)
|
|
||||||
for (int i = 0; i < NUM_RINGTONES_AND_SOME; i++) {
|
|
||||||
sendKeys(top ? KeyEvent.KEYCODE_DPAD_UP : KeyEvent.KEYCODE_DPAD_DOWN);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user