Move tests from tests/app/ to tests/unit/
- second round, move all remaining items - removed SoundSettingsIntegrationTest and DashboardAdapterTest as they are obsolete. Fixes: 62103184 Test: make SettingsUnitTests Change-Id: Idc2eeb285acd209ef2d00c5451fff697002e1734
This commit is contained in:
@@ -1,27 +0,0 @@
|
||||
LOCAL_PATH:= $(call my-dir)
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
# We only want this apk build for tests.
|
||||
LOCAL_MODULE_TAGS := tests
|
||||
LOCAL_CERTIFICATE := platform
|
||||
|
||||
LOCAL_JAVA_LIBRARIES := android.test.runner bouncycastle
|
||||
|
||||
LOCAL_STATIC_JAVA_LIBRARIES := \
|
||||
android-support-test \
|
||||
mockito-target \
|
||||
espresso-core \
|
||||
espresso-contrib-nodep \
|
||||
espresso-intents-nodep \
|
||||
ub-uiautomator \
|
||||
truth-prebuilt \
|
||||
legacy-android-test
|
||||
|
||||
# Include all test java files.
|
||||
LOCAL_SRC_FILES := $(call all-java-files-under, src)
|
||||
|
||||
LOCAL_PACKAGE_NAME := SettingsTests
|
||||
|
||||
LOCAL_INSTRUMENTATION_FOR := Settings
|
||||
|
||||
include $(BUILD_PACKAGE)
|
@@ -1,67 +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.settings.tests">
|
||||
|
||||
<uses-permission android:name="android.permission.BLUETOOTH" />
|
||||
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
|
||||
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
|
||||
<uses-permission android:name="android.permission.INTERACT_ACROSS_USERS" />
|
||||
<uses-permission android:name="android.permission.UPDATE_APP_OPS_STATS" />
|
||||
|
||||
<application>
|
||||
<uses-library android:name="android.test.runner" />
|
||||
<activity android:name="BluetoothRequestPermissionTest"
|
||||
android:label="Bluetooth Perm Test" >
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity android:name="Operator" android:label="Operator Hook Test" >
|
||||
<intent-filter>
|
||||
<action android:name="com.android.settings.OPERATOR_APPLICATION_SETTING" />
|
||||
</intent-filter>
|
||||
<meta-data android:name="com.android.settings.title" android:resource="@string/operator_settings_title" />
|
||||
<meta-data android:name="com.android.settings.summary" android:resource="@string/operator_settings_summary" />
|
||||
<meta-data android:name="com.android.settings.icon" android:resource="@drawable/ic_settings_applications" />
|
||||
</activity>
|
||||
<activity android:name="Manufacturer" android:label="Manufacturer Hook Test" >
|
||||
<intent-filter>
|
||||
<action android:name="com.android.settings.MANUFACTURER_APPLICATION_SETTING" />
|
||||
</intent-filter>
|
||||
<meta-data android:name="com.android.settings.title" android:resource="@string/manufacturer_settings_title" />
|
||||
<meta-data android:name="com.android.settings.summary" android:resource="@string/manufacturer_settings_summary" />
|
||||
<meta-data android:name="com.android.settings.icon" android:resource="@drawable/ic_settings_applications" />
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
<instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
|
||||
android:targetPackage="com.android.settings"
|
||||
android:label="Settings Test Cases">
|
||||
</instrumentation>
|
||||
|
||||
<instrumentation android:name="SettingsLaunchPerformance"
|
||||
android:targetPackage="com.android.settings"
|
||||
android:label="Settings Launch Performance">
|
||||
</instrumentation>
|
||||
|
||||
</manifest>
|
@@ -1,83 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2016 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.settings.notification;
|
||||
|
||||
import static android.support.test.espresso.Espresso.onView;
|
||||
import static android.support.test.espresso.assertion.ViewAssertions.matches;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.hasDescendant;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.withId;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.withText;
|
||||
import static org.hamcrest.Matchers.allOf;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
|
||||
import android.content.Context;
|
||||
import android.media.AudioManager;
|
||||
import android.support.test.espresso.contrib.RecyclerViewActions;
|
||||
import android.support.test.filters.SmallTest;
|
||||
import android.support.test.rule.ActivityTestRule;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Settings;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
@SmallTest
|
||||
public class SoundSettingsIntegrationTest {
|
||||
|
||||
private AudioManager mAudioManager;
|
||||
private final String TRUNCATED_SUMMARY = "Ring volume at";
|
||||
|
||||
@Rule
|
||||
public ActivityTestRule<Settings> mActivityRule =
|
||||
new ActivityTestRule<>(Settings.class, true);
|
||||
|
||||
@Test
|
||||
public void soundPreferenceShowsCorrectSummaryOnSilentMode() {
|
||||
mAudioManager = (AudioManager) mActivityRule.getActivity().getApplicationContext()
|
||||
.getSystemService(Context.AUDIO_SERVICE);
|
||||
mAudioManager.setRingerMode(AudioManager.RINGER_MODE_SILENT);
|
||||
onView(withId(R.id.dashboard_container))
|
||||
.perform(RecyclerViewActions.scrollTo(
|
||||
hasDescendant(withText(R.string.sound_settings))));
|
||||
onView(withText(R.string.sound_settings_summary_silent)).check(matches(isDisplayed()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void soundPreferenceShowsCorrectSummaryOnVibrateMode() {
|
||||
mAudioManager = (AudioManager) mActivityRule.getActivity().getApplicationContext()
|
||||
.getSystemService(Context.AUDIO_SERVICE);
|
||||
mAudioManager.setRingerMode(AudioManager.RINGER_MODE_VIBRATE);
|
||||
onView(withId(R.id.dashboard_container)).perform(RecyclerViewActions
|
||||
.scrollTo(hasDescendant(withText(R.string.sound_settings))));
|
||||
onView(withText(R.string.sound_settings_summary_vibrate)).check(matches(isDisplayed()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void soundPreferenceShowsCorrectSummaryOnMaxVolume() {
|
||||
mAudioManager = (AudioManager) mActivityRule.getActivity().getApplicationContext()
|
||||
.getSystemService(Context.AUDIO_SERVICE);
|
||||
mAudioManager.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
|
||||
mAudioManager.setStreamVolume(AudioManager.STREAM_RING,
|
||||
mAudioManager.getStreamMaxVolume(AudioManager.STREAM_RING), 0);
|
||||
onView(withId(R.id.dashboard_container))
|
||||
.perform(RecyclerViewActions.scrollTo(
|
||||
hasDescendant(withText(R.string.sound_settings))));
|
||||
onView(withText(containsString(TRUNCATED_SUMMARY))).check(matches(isDisplayed()));
|
||||
}
|
||||
}
|
@@ -1,62 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2016 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.settings.tests;
|
||||
|
||||
import android.app.Instrumentation;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.provider.Settings;
|
||||
import android.support.test.InstrumentationRegistry;
|
||||
import android.support.test.filters.SmallTest;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import com.android.settings.R;
|
||||
|
||||
import static android.support.test.espresso.Espresso.onView;
|
||||
import static android.support.test.espresso.action.ViewActions.click;
|
||||
import static android.support.test.espresso.assertion.ViewAssertions.matches;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.*;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.Visibility.VISIBLE;
|
||||
import static org.hamcrest.core.AllOf.allOf;
|
||||
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
@SmallTest
|
||||
public class DashboardAdapterTest {
|
||||
@Before
|
||||
public void SetUp() {
|
||||
Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation();
|
||||
instrumentation.startActivitySync(new Intent(Settings
|
||||
.ACTION_SETTINGS));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTileConsistency_ToggleSuggestionsAndOpenBluetooth_shouldInBluetooth()
|
||||
throws Exception{
|
||||
final Context context = InstrumentationRegistry.getTargetContext();
|
||||
|
||||
onView(allOf(withText(context.getString(R.string.suggestions_title)),
|
||||
withEffectiveVisibility(VISIBLE))).perform(click());
|
||||
onView(allOf(withText(context.getString(R.string.bluetooth_settings)),
|
||||
withEffectiveVisibility(VISIBLE))).perform(click());
|
||||
|
||||
// It should go to Bluetooth sub page, not other page or crash
|
||||
onView(allOf(withText(context.getString(R.string.bluetooth_settings)),
|
||||
withEffectiveVisibility(VISIBLE))).check(matches(isDisplayed()));
|
||||
|
||||
}
|
||||
}
|
@@ -14,6 +14,7 @@ LOCAL_STATIC_JAVA_LIBRARIES := \
|
||||
mockito-target-minus-junit4 \
|
||||
truth-prebuilt \
|
||||
ub-uiautomator \
|
||||
espresso-contrib-nodep \
|
||||
espresso-intents-nodep \
|
||||
|
||||
|
||||
|
@@ -17,8 +17,41 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.android.settings.tests.unit">
|
||||
|
||||
<uses-permission android:name="android.permission.BLUETOOTH" />
|
||||
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
|
||||
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
|
||||
<uses-permission android:name="android.permission.INTERACT_ACROSS_USERS" />
|
||||
<uses-permission android:name="android.permission.UPDATE_APP_OPS_STATS" />
|
||||
|
||||
<application>
|
||||
<uses-library android:name="android.test.runner" />
|
||||
<activity android:name="com.android.settings.tests.BluetoothRequestPermissionTest"
|
||||
android:label="Bluetooth Perm Test" >
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity android:name="Operator" android:label="Operator Hook Test" >
|
||||
<intent-filter>
|
||||
<action android:name="com.android.settings.OPERATOR_APPLICATION_SETTING" />
|
||||
</intent-filter>
|
||||
<meta-data android:name="com.android.settings.title" android:resource="@string/operator_settings_title" />
|
||||
<meta-data android:name="com.android.settings.summary" android:resource="@string/operator_settings_summary" />
|
||||
<meta-data android:name="com.android.settings.icon" android:resource="@drawable/ic_settings_applications" />
|
||||
</activity>
|
||||
<activity android:name="Manufacturer" android:label="Manufacturer Hook Test" >
|
||||
<intent-filter>
|
||||
<action android:name="com.android.settings.MANUFACTURER_APPLICATION_SETTING" />
|
||||
</intent-filter>
|
||||
<meta-data android:name="com.android.settings.title" android:resource="@string/manufacturer_settings_title" />
|
||||
<meta-data android:name="com.android.settings.summary" android:resource="@string/manufacturer_settings_summary" />
|
||||
<meta-data android:name="com.android.settings.icon" android:resource="@drawable/ic_settings_applications" />
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
<instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
|
||||
@@ -26,4 +59,9 @@
|
||||
android:label="Settings Test Cases">
|
||||
</instrumentation>
|
||||
|
||||
<instrumentation android:name="com.android.settings.tests.SettingsLaunchPerformance"
|
||||
android:targetPackage="com.android.settings"
|
||||
android:label="Settings Launch Performance">
|
||||
</instrumentation>
|
||||
|
||||
</manifest>
|
||||
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
@@ -17,8 +17,6 @@
|
||||
package com.android.settings;
|
||||
|
||||
import com.android.settings.Settings;
|
||||
import com.android.settings.tests.Manufacturer;
|
||||
import com.android.settings.tests.Operator;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@@ -41,7 +39,7 @@ import java.util.List;
|
||||
*/
|
||||
public class SettingsHookTests extends ActivityInstrumentationTestCase2<Settings> {
|
||||
|
||||
private static final String PACKAGE_NAME = "com.android.settings.tests";
|
||||
private static final String PACKAGE_NAME = "com.android.settings.tests.unit";
|
||||
|
||||
private static final String KEY_SETTINGS_ROOT = "parent";
|
||||
private static final String KEY_SETTINGS_OPERATOR = "operator_settings";
|
@@ -67,6 +67,9 @@ public class DefaultAppSettingsTest extends InstrumentationTestCase {
|
||||
final String titleApps = mTargetContext.getResources().getString(
|
||||
R.string.app_and_notification_dashboard_title);
|
||||
mDevice.findObject(new UiSelector().text(titleApps)).click();
|
||||
final String titleAdvance = mTargetContext.getResources().getString(
|
||||
R.string.advanced_section_header);
|
||||
mDevice.findObject(new UiSelector().text(titleAdvance)).click();
|
||||
final String titleDefaultApps = mTargetContext.getResources().getString(
|
||||
R.string.app_default_dashboard_title);
|
||||
mDevice.findObject(new UiSelector().text(titleDefaultApps)).click();
|
@@ -19,7 +19,7 @@ import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
|
||||
@SmallTest
|
||||
public class StorageDashboardFragmentEspressoTest {
|
||||
public class StorageDashboardFragmentTest {
|
||||
|
||||
public static final String EXTRA_KEY = ":settings:show_fragment";
|
||||
|
||||
@@ -30,7 +30,7 @@ public class StorageDashboardFragmentEspressoTest {
|
||||
@Test
|
||||
public void testStorageManagePreference_canClickTextView() throws InterruptedException {
|
||||
// Click on the actual textbox instead of just somewhere in the preference
|
||||
onView(withText(R.string.storage_menu_manage)).perform(click());
|
||||
onView(withText(R.string.automatic_storage_manager_preference_title)).perform(click());
|
||||
|
||||
// Check that it worked by seeing if we switched screens
|
||||
intended(hasExtra(equalTo(EXTRA_KEY),
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user