From 0047944c2e7a6cfd8b98e748857707bd9edaec10 Mon Sep 17 00:00:00 2001 From: Fan Zhang Date: Mon, 25 Feb 2019 16:05:36 -0800 Subject: [PATCH] Clean up instrumentation tests - Fixed some important tests - Deleted some useless tests - Some tests are still broken, filed bugs for these Fixes: 124572765 Test: atest Change-Id: Iac4e6a1fb1dbf9383d91945525df69a651ae77fd --- .../com/android/settings/DisplaySettingsTest.java | 59 --------- .../settings/EncryptionInterstitialTest.java | 110 ---------------- .../settings/ManagedAccessSettingsLowRamTest.java | 126 ------------------- .../RegulatoryInfoDisplayActivityTest.java | 81 ------------ .../com/android/settings/SettingsHookTests.java | 130 ------------------- ...ccessibilityShortcutPreferenceFragmentTest.java | 17 +-- .../applications/DefaultAppSettingsTest.java | 79 ------------ .../applications/ManageApplicationsLaunchTest.java | 58 --------- .../applications/SpecialAppAccessSettingsTest.java | 97 -------------- .../android/settings/backup/BackupIntentTest.java | 2 +- .../BluetoothDeviceDetailsRotationTest.java | 106 ---------------- .../bluetooth/DevicePickerActivityTest.java | 47 ------- .../ConnectedDeviceActivityTest.java | 68 ---------- .../settings/dashboard/PreferenceThemeTest.java | 18 --- .../datausage/MobileDataUsageActivityTest.java | 64 ---------- .../datetime/timezone/model/TimeZoneDataTest.java | 3 - .../deviceinfo/StorageDashboardFragmentTest.java | 41 ------ .../settings/dream/DreamSettingsLaunchTest.java | 41 ------ .../settings/tests/DrawOverlayDetailsTest.java | 77 ------------ .../android/settings/tests/KeepOnScreenTest.java | 72 ----------- .../settings/tests/PrivateVolumeSettingsTest.java | 42 ------- .../tests/SettingsRestoreAfterCloseTest.java | 84 ------------- .../android/settings/users/UserSettingsTest.java | 140 --------------------- .../wifi/tether/WifiTetherSettingsTest.java | 4 +- 24 files changed, 4 insertions(+), 1562 deletions(-) delete mode 100644 tests/unit/src/com/android/settings/DisplaySettingsTest.java delete mode 100644 tests/unit/src/com/android/settings/EncryptionInterstitialTest.java delete mode 100644 tests/unit/src/com/android/settings/ManagedAccessSettingsLowRamTest.java delete mode 100644 tests/unit/src/com/android/settings/SettingsHookTests.java delete mode 100644 tests/unit/src/com/android/settings/applications/DefaultAppSettingsTest.java delete mode 100644 tests/unit/src/com/android/settings/applications/ManageApplicationsLaunchTest.java delete mode 100644 tests/unit/src/com/android/settings/applications/SpecialAppAccessSettingsTest.java delete mode 100644 tests/unit/src/com/android/settings/bluetooth/BluetoothDeviceDetailsRotationTest.java delete mode 100644 tests/unit/src/com/android/settings/bluetooth/DevicePickerActivityTest.java delete mode 100644 tests/unit/src/com/android/settings/connecteddevice/ConnectedDeviceActivityTest.java delete mode 100644 tests/unit/src/com/android/settings/datausage/MobileDataUsageActivityTest.java delete mode 100644 tests/unit/src/com/android/settings/deviceinfo/StorageDashboardFragmentTest.java delete mode 100644 tests/unit/src/com/android/settings/dream/DreamSettingsLaunchTest.java delete mode 100644 tests/unit/src/com/android/settings/tests/DrawOverlayDetailsTest.java delete mode 100644 tests/unit/src/com/android/settings/tests/KeepOnScreenTest.java delete mode 100644 tests/unit/src/com/android/settings/tests/PrivateVolumeSettingsTest.java delete mode 100644 tests/unit/src/com/android/settings/tests/SettingsRestoreAfterCloseTest.java delete mode 100644 tests/unit/src/com/android/settings/users/UserSettingsTest.java diff --git a/tests/unit/src/com/android/settings/DisplaySettingsTest.java b/tests/unit/src/com/android/settings/DisplaySettingsTest.java deleted file mode 100644 index cc9cd81931..0000000000 --- a/tests/unit/src/com/android/settings/DisplaySettingsTest.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (C) 2017 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; - -import static androidx.test.espresso.Espresso.onView; -import static androidx.test.espresso.action.ViewActions.click; -import static androidx.test.espresso.matcher.ViewMatchers.withText; - -import android.app.Instrumentation; -import android.content.Context; -import android.content.Intent; -import android.support.test.uiautomator.UiDevice; - -import androidx.test.InstrumentationRegistry; -import androidx.test.filters.SmallTest; -import androidx.test.runner.AndroidJUnit4; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; - -@RunWith(AndroidJUnit4.class) -@SmallTest -public class DisplaySettingsTest { - - private Instrumentation mInstrumentation; - private Context mContext; - private UiDevice mDevice; - - @Before - public void setUp() { - mInstrumentation = InstrumentationRegistry.getInstrumentation(); - mContext = mInstrumentation.getTargetContext(); - mDevice = UiDevice.getInstance(mInstrumentation); - } - - @Test - public void launchBrightnessLevel_shouldNotCrash() { - mInstrumentation.startActivitySync( - new Intent(mContext, DisplaySettings.class)); - onView(withText(mContext.getString(R.string.brightness))).perform(click()); - // should not crash - mDevice.pressBack(); // dismiss the brightness dialog - } -} diff --git a/tests/unit/src/com/android/settings/EncryptionInterstitialTest.java b/tests/unit/src/com/android/settings/EncryptionInterstitialTest.java deleted file mode 100644 index 503a78c6bb..0000000000 --- a/tests/unit/src/com/android/settings/EncryptionInterstitialTest.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (C) 2017 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; - -import static androidx.test.espresso.Espresso.onView; -import static androidx.test.espresso.action.ViewActions.click; -import static androidx.test.espresso.matcher.ViewMatchers.withId; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import android.app.Activity; -import android.app.Instrumentation; -import android.app.Instrumentation.ActivityMonitor; -import android.app.Instrumentation.ActivityResult; -import android.content.Context; -import android.content.Intent; - -import androidx.test.InstrumentationRegistry; -import androidx.test.filters.MediumTest; -import androidx.test.runner.AndroidJUnit4; - -import com.google.android.setupcompat.PartnerCustomizationLayout; -import com.google.android.setupcompat.template.FooterBarMixin; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; - -@RunWith(AndroidJUnit4.class) -@MediumTest -public class EncryptionInterstitialTest { - - private Instrumentation mInstrumentation; - private Context mContext; - private TestActivityMonitor mActivityMonitor; - - @Before - public void setUp() { - mInstrumentation = InstrumentationRegistry.getInstrumentation(); - mContext = mInstrumentation.getTargetContext(); - mActivityMonitor = new TestActivityMonitor(); - mInstrumentation.addMonitor(mActivityMonitor); - } - - @After - public void tearDown() { - mInstrumentation.removeMonitor(mActivityMonitor); - } - - @Test - public void clickYes_shouldRequirePassword() { - final Activity activity = mInstrumentation.startActivitySync( - new Intent(mContext, EncryptionInterstitial.class) - .putExtra("extra_unlock_method_intent", new Intent("test.unlock.intent"))); - final PartnerCustomizationLayout layout = activity.findViewById(R.id.setup_wizard_layout); - layout.getMixin(FooterBarMixin.class).getPrimaryButtonView().performClick(); - - mActivityMonitor.waitForActivityWithTimeout(1000); - assertEquals(1, mActivityMonitor.getHits()); - - assertTrue(mActivityMonitor.mMatchedIntent.getBooleanExtra( - EncryptionInterstitial.EXTRA_REQUIRE_PASSWORD, false)); - } - - @Test - public void clickNo_shouldNotRequirePassword() { - final Activity activity = mInstrumentation.startActivitySync( - new Intent(mContext, EncryptionInterstitial.class) - .putExtra("extra_unlock_method_intent", new Intent("test.unlock.intent"))); - final PartnerCustomizationLayout layout = activity.findViewById(R.id.setup_wizard_layout); - layout.getMixin(FooterBarMixin.class).getSecondaryButtonView().performClick(); - - mActivityMonitor.waitForActivityWithTimeout(1000); - assertEquals(1, mActivityMonitor.getHits()); - - assertFalse(mActivityMonitor.mMatchedIntent.getBooleanExtra( - EncryptionInterstitial.EXTRA_REQUIRE_PASSWORD, true)); - } - - private static class TestActivityMonitor extends ActivityMonitor { - - Intent mMatchedIntent = null; - - @Override - public ActivityResult onStartActivity(Intent intent) { - if ("test.unlock.intent".equals(intent.getAction())) { - mMatchedIntent = intent; - return new ActivityResult(Activity.RESULT_OK, null); - } - return null; - } - } -} diff --git a/tests/unit/src/com/android/settings/ManagedAccessSettingsLowRamTest.java b/tests/unit/src/com/android/settings/ManagedAccessSettingsLowRamTest.java deleted file mode 100644 index 426b8a4270..0000000000 --- a/tests/unit/src/com/android/settings/ManagedAccessSettingsLowRamTest.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (C) 2017 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; - -import static androidx.test.espresso.Espresso.onView; -import static androidx.test.espresso.action.ViewActions.click; -import static androidx.test.espresso.assertion.ViewAssertions.doesNotExist; -import static androidx.test.espresso.assertion.ViewAssertions.matches; -import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; -import static androidx.test.espresso.matcher.ViewMatchers.withText; - -import android.app.ActivityManager; -import android.app.Instrumentation; -import android.content.Context; -import android.content.Intent; -import android.provider.Settings; - -import androidx.test.InstrumentationRegistry; -import androidx.test.filters.SmallTest; -import androidx.test.runner.AndroidJUnit4; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; - -@RunWith(AndroidJUnit4.class) -@SmallTest -public class ManagedAccessSettingsLowRamTest { - - private Instrumentation mInstrumentation; - private Context mTargetContext; - - @Before - public void setUp() { - mInstrumentation = InstrumentationRegistry.getInstrumentation(); - mTargetContext = mInstrumentation.getTargetContext(); - } - - @Test - public void testManagedAccessOptionsVisibility() throws Exception { - mInstrumentation.startActivitySync(new Intent(mTargetContext, - com.android.settings.Settings.AppAndNotificationDashboardActivity.class)); - onView(withText(mTargetContext.getString(R.string.expand_button_title))).perform(click()); - onView(withText(mTargetContext.getString(R.string.special_access))).perform(click()); - - String[] managedServiceLabels = new String[] {"Do Not Disturb access", - "VR helper services", "Notification access", "Picture-in-picture"}; - for (String label : managedServiceLabels) { - if (ActivityManager.isLowRamDeviceStatic()) { - onView(withText(label)).check(doesNotExist()); - } else { - onView(withText(label)).check(matches(isDisplayed())); - } - } - } - - @Test - public void launchNotificationSetting_onlyWorksIfNotLowRam() { - final Intent intent = new Intent(Settings.ACTION_NOTIFICATION_LISTENER_SETTINGS); - - mInstrumentation.startActivitySync(intent); - - final String label = "This feature is not available on this device"; - if (ActivityManager.isLowRamDeviceStatic()) { - onView(withText(label)).check(matches(isDisplayed())); - } else { - onView(withText(label)).check(doesNotExist()); - } - } - - @Test - public void launchDndSetting_onlyWorksIfNotLowRam() { - final Intent intent = new Intent(Settings.ACTION_NOTIFICATION_POLICY_ACCESS_SETTINGS); - - mInstrumentation.startActivitySync(intent); - - final String label = "This feature is not available on this device"; - if (ActivityManager.isLowRamDeviceStatic()) { - onView(withText(label)).check(matches(isDisplayed())); - } else { - onView(withText(label)).check(doesNotExist()); - } - } - - @Test - public void launchVrSetting_onlyWorksIfNotLowRam() { - final Intent intent = new Intent(Settings.ACTION_VR_LISTENER_SETTINGS); - - mInstrumentation.startActivitySync(intent); - - final String label = "This feature is not available on this device"; - if (ActivityManager.isLowRamDeviceStatic()) { - onView(withText(label)).check(matches(isDisplayed())); - } else { - onView(withText(label)).check(doesNotExist()); - } - } - - @Test - public void launchPictureInPictureSetting_onlyWorksIfNotLowRam() { - final Intent intent = new Intent(Settings.ACTION_PICTURE_IN_PICTURE_SETTINGS); - - mInstrumentation.startActivitySync(intent); - - final String label = "This feature is not available on this device"; - if (ActivityManager.isLowRamDeviceStatic()) { - onView(withText(label)).check(matches(isDisplayed())); - } else { - onView(withText(label)).check(doesNotExist()); - } - } -} diff --git a/tests/unit/src/com/android/settings/RegulatoryInfoDisplayActivityTest.java b/tests/unit/src/com/android/settings/RegulatoryInfoDisplayActivityTest.java index 48f9f5d53f..1701ddff90 100644 --- a/tests/unit/src/com/android/settings/RegulatoryInfoDisplayActivityTest.java +++ b/tests/unit/src/com/android/settings/RegulatoryInfoDisplayActivityTest.java @@ -16,12 +16,6 @@ package com.android.settings; -import static androidx.test.espresso.Espresso.onView; -import static androidx.test.espresso.assertion.ViewAssertions.matches; -import static androidx.test.espresso.matcher.RootMatchers.isDialog; -import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; -import static androidx.test.espresso.matcher.ViewMatchers.withId; - import static junit.framework.Assert.fail; import android.app.Instrumentation; @@ -29,8 +23,6 @@ import android.app.UiAutomation; import android.content.Context; import android.content.Intent; import android.content.pm.ResolveInfo; -import android.graphics.Bitmap; -import android.util.Log; import androidx.test.InstrumentationRegistry; import androidx.test.filters.SmallTest; @@ -40,10 +32,6 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; - @RunWith(AndroidJUnit4.class) @SmallTest public class RegulatoryInfoDisplayActivityTest { @@ -82,73 +70,4 @@ public class RegulatoryInfoDisplayActivityTest { return; } } - - @Test - public void launchRegulatoryInfo_shouldNotCrash() { - final Context context = mInstrumentation.getTargetContext(); - final boolean hasRegulatoryInfo = context.getResources() - .getBoolean(R.bool.config_show_regulatory_info); - - if (!hasRegulatoryInfo) { - return; - } - // Launch intent - mInstrumentation.startActivitySync(mRegulatoryInfoIntent); - - onView(withId(R.id.regulatoryInfo)) - .inRoot(isDialog()) - .check(matches(isDisplayed())); - } - - @Test - public void launchRegulatoryInfo_withInfoImage_shouldDisplay() throws IOException { - // TODO: Remove "setenforce 0" when selinux rules is updated to give read permission for - // regulatory info. - mUiAutomation.executeShellCommand("setenforce 0"); - - final boolean tempFileCreated = ensureRegulatoryInfoImageExists(); - try { - final Context context = mInstrumentation.getTargetContext(); - final boolean hasRegulatoryInfo = context.getResources() - .getBoolean(R.bool.config_show_regulatory_info); - - if (!hasRegulatoryInfo) { - return; - } - // Launch intent - mInstrumentation.startActivitySync(mRegulatoryInfoIntent); - - onView(withId(R.id.regulatoryInfo)) - .inRoot(isDialog()) - .check(matches(isDisplayed())); - } finally { - if (tempFileCreated) { - final String filename = - RegulatoryInfoDisplayActivity.getRegulatoryInfoImageFileName(); - new File(filename).delete(); - Log.d(TAG, "Deleting temp file " + filename); - } - } - } - - /** - * Ensures regulatory label image exists on disk. - * - * @return true if a test image is created. - */ - private boolean ensureRegulatoryInfoImageExists() throws IOException { - final String filename = RegulatoryInfoDisplayActivity.getRegulatoryInfoImageFileName(); - if (new File(filename).exists()) { - return false; - } - Log.d(TAG, "Creating temp file " + filename); - final Bitmap bitmap = Bitmap.createBitmap(400 /* width */, 400 /* height */, - Bitmap.Config.ARGB_8888); - final FileOutputStream out = new FileOutputStream(filename); - bitmap.compress(Bitmap.CompressFormat.PNG, 100 /* quality */, out); - out.close(); - return true; - } - - } diff --git a/tests/unit/src/com/android/settings/SettingsHookTests.java b/tests/unit/src/com/android/settings/SettingsHookTests.java deleted file mode 100644 index ee0bbb6e07..0000000000 --- a/tests/unit/src/com/android/settings/SettingsHookTests.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright (C) 2010 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; - -import android.content.Context; -import android.content.Intent; -import android.content.pm.ApplicationInfo; -import android.content.pm.PackageManager; -import android.content.pm.ResolveInfo; -import android.test.ActivityInstrumentationTestCase2; - -import java.util.List; - -/** - * Tests for the Settings operator/manufacturer hook. - * - * Running all tests: - * - * make SettingsTests - * adb push SettingsTests.apk /system/app/SettingsTests.apk - * adb shell am instrument \ - * -w com.android.settings.tests/android.test.InstrumentationTestRunner - */ -public class SettingsHookTests extends ActivityInstrumentationTestCase2 { - - 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"; - private static final String KEY_SETTINGS_MANUFACTURER = "manufacturer_settings"; - - private static final String INTENT_OPERATOR_HOOK = "com.android.settings.OPERATOR_APPLICATION_SETTING"; - private static final String INTENT_MANUFACTURER_HOOK = "com.android.settings.MANUFACTURER_APPLICATION_SETTING"; - - private Settings mSettings; - - public SettingsHookTests() { - super("com.android.settings", Settings.class); - } - - @Override - protected void setUp() throws Exception { - super.setUp(); - mSettings = getActivity(); - } - - /** - * Test that the operator/manufacturer settings hook test application is - * available and that it's installed in the device's system image. - */ - public void testSettingsHookTestAppAvailable() throws Exception { - Context context = mSettings.getApplicationContext(); - PackageManager pm = context.getPackageManager(); - ApplicationInfo applicationInfo = pm.getApplicationInfo(PACKAGE_NAME, 0); - assertTrue((applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0); - } - - /** - * Test that the operator test activity has registered an intent-filter for - * an action named 'android.settings.OPERATOR_APPLICATION_SETTING'. - */ - public void testOperatorIntentFilter() { - boolean result = false; - Context context = mSettings.getApplicationContext(); - PackageManager pm = context.getPackageManager(); - Intent intent = new Intent(INTENT_OPERATOR_HOOK); - List list = pm.queryIntentActivities(intent, 0); - for (ResolveInfo resolveInfo : list) { - if (resolveInfo.activityInfo.packageName.equals(PACKAGE_NAME)) { - result = true; - } - } - assertTrue("Intent-filter not found", result); - } - - /** - * Test that the manufacturer test activity has registered an intent-filter - * for an action named 'android.settings.MANUFACTURER_APPLICATION_SETTING'. - */ - public void testManufacturerIntentFilter() { - boolean result = false; - Context context = mSettings.getApplicationContext(); - PackageManager pm = context.getPackageManager(); - Intent intent = new Intent(INTENT_MANUFACTURER_HOOK); - List list = pm.queryIntentActivities(intent, 0); - for (ResolveInfo resolveInfo : list) { - if (resolveInfo.activityInfo.packageName.equals(PACKAGE_NAME)) { - result = true; - } - } - assertTrue("Intent-filter not found", result); - } - - /** - * Test that the operator preference is available in the Settings - * application. - */ - public void testOperatorPreferenceAvailable() { -// TODO: fix this test case to work with fragments -// PreferenceGroup root = (PreferenceGroup)mSettings.findPreference(KEY_SETTINGS_ROOT); -// Preference operatorPreference = root.findPreference(KEY_SETTINGS_OPERATOR); -// assertNotNull(operatorPreference); - } - - /** - * Test that the manufacturer preference is available in the Settings - * application. - */ - public void testManufacturerPreferenceAvailable() { -// TODO: fix this test case to work with fragments -// PreferenceGroup root = (PreferenceGroup)mSettings.findPreference(KEY_SETTINGS_ROOT); -// Preference manufacturerHook = root.findPreference(KEY_SETTINGS_MANUFACTURER); -// assertNotNull(manufacturerHook); - } - -} diff --git a/tests/unit/src/com/android/settings/accessibility/AccessibilityShortcutPreferenceFragmentTest.java b/tests/unit/src/com/android/settings/accessibility/AccessibilityShortcutPreferenceFragmentTest.java index f8d06a8a83..0c27379a0f 100644 --- a/tests/unit/src/com/android/settings/accessibility/AccessibilityShortcutPreferenceFragmentTest.java +++ b/tests/unit/src/com/android/settings/accessibility/AccessibilityShortcutPreferenceFragmentTest.java @@ -30,6 +30,7 @@ import static org.hamcrest.Matchers.allOf; import android.app.Instrumentation; import android.os.Bundle; + import android.provider.Settings; import android.widget.CompoundButton; @@ -64,14 +65,6 @@ public class AccessibilityShortcutPreferenceFragmentTest { } @Test - public void lockScreenPreference_defaultBeforeDialogShown_isOff() { - setDialogShown(false); - setOnLockscreen(null); - startFragment(); - assertLockscreenSwitchIsCheckedIs(false); - } - - @Test public void lockScreenPreference_setOnBeforeDialogShown_isOn() { setDialogShown(false); setOnLockscreen(true); @@ -87,14 +80,6 @@ public class AccessibilityShortcutPreferenceFragmentTest { assertLockscreenSwitchIsCheckedIs(true); } - @Test - public void lockScreenPreference_setOffAfterDialogShown_isOn() { - setDialogShown(true); - setOnLockscreen(false); - startFragment(); - assertLockscreenSwitchIsCheckedIs(false); - } - private void startFragment() { mInstrumentation.runOnMainSync(() -> { new SubSettingLauncher(mActivity) diff --git a/tests/unit/src/com/android/settings/applications/DefaultAppSettingsTest.java b/tests/unit/src/com/android/settings/applications/DefaultAppSettingsTest.java deleted file mode 100644 index 1dd899eb7e..0000000000 --- a/tests/unit/src/com/android/settings/applications/DefaultAppSettingsTest.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (C) 2017 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.applications; - -import android.content.Context; -import android.content.Intent; -import android.support.test.uiautomator.UiDevice; -import android.support.test.uiautomator.UiObject; -import android.support.test.uiautomator.UiSelector; -import android.test.InstrumentationTestCase; -import android.widget.TextView; - -import androidx.test.filters.SmallTest; - -import com.android.settings.R; - -import org.junit.Test; - -/** - * Test for Advanced App preferences. - */ -@SmallTest -public class DefaultAppSettingsTest extends InstrumentationTestCase { - - private UiDevice mDevice; - private Context mTargetContext; - private String mTargetPackage; - - @Override - protected void setUp() throws Exception { - super.setUp(); - mDevice = UiDevice.getInstance(getInstrumentation()); - mTargetContext = getInstrumentation().getTargetContext(); - mTargetPackage = mTargetContext.getPackageName(); - } - - @Test - public void testSelectDefaultHome_shouldLaunchHomePicker() throws Exception { - launchDefaultApps(); - final String titleHomeApp = mTargetContext.getResources().getString(R.string.home_app); - mDevice.findObject(new UiSelector().text(titleHomeApp)).click(); - final UiObject actionBar = mDevice.findObject(new UiSelector().resourceId( - "com.android.settings:id/action_bar")); - final UiObject title = actionBar.getChild( - new UiSelector().className(TextView.class.getName())); - assertEquals(titleHomeApp, title.getText()); - } - - private void launchDefaultApps() throws Exception { - final Intent settingsIntent = new Intent(Intent.ACTION_MAIN) - .addCategory(Intent.CATEGORY_LAUNCHER) - .setPackage(mTargetPackage) - .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - getInstrumentation().getContext().startActivity(settingsIntent); - 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(); - } - -} diff --git a/tests/unit/src/com/android/settings/applications/ManageApplicationsLaunchTest.java b/tests/unit/src/com/android/settings/applications/ManageApplicationsLaunchTest.java deleted file mode 100644 index c98a43d5c8..0000000000 --- a/tests/unit/src/com/android/settings/applications/ManageApplicationsLaunchTest.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (C) 2017 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.applications; - -import static androidx.test.espresso.Espresso.onView; -import static androidx.test.espresso.assertion.ViewAssertions.matches; -import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; -import static androidx.test.espresso.matcher.ViewMatchers.withText; - -import static org.hamcrest.Matchers.allOf; - -import android.app.Instrumentation; -import android.content.Intent; -import android.provider.Settings; - -import androidx.test.InstrumentationRegistry; -import androidx.test.filters.SmallTest; -import androidx.test.runner.AndroidJUnit4; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; - -@SmallTest -@RunWith(AndroidJUnit4.class) -public class ManageApplicationsLaunchTest { - - private Instrumentation mInstrumentation; - - @Before - public void setUp() { - mInstrumentation = InstrumentationRegistry.getInstrumentation(); - } - - @Test - public void launchAppsSettings_shouldShowAppList() throws Exception { - final Intent appsSettingsIntent = new - Intent(Settings.ACTION_MANAGE_APPLICATIONS_SETTINGS); - - mInstrumentation.startActivitySync(appsSettingsIntent); - - onView(allOf(withText("Calculator"))).check(matches(isDisplayed())); - } -} diff --git a/tests/unit/src/com/android/settings/applications/SpecialAppAccessSettingsTest.java b/tests/unit/src/com/android/settings/applications/SpecialAppAccessSettingsTest.java deleted file mode 100644 index 4738d594a0..0000000000 --- a/tests/unit/src/com/android/settings/applications/SpecialAppAccessSettingsTest.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (C) 2017 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.applications; - -import android.content.Context; -import android.content.Intent; -import android.support.test.uiautomator.UiDevice; -import android.support.test.uiautomator.UiObject; -import android.support.test.uiautomator.UiObjectNotFoundException; -import android.support.test.uiautomator.UiScrollable; -import android.support.test.uiautomator.UiSelector; -import android.test.InstrumentationTestCase; -import android.widget.TextView; - -import androidx.test.filters.SmallTest; - -import com.android.settings.R; - -import org.junit.Test; - -/** - * Test for Special App Access preferences. - */ -@SmallTest -public class SpecialAppAccessSettingsTest extends InstrumentationTestCase { - - private UiDevice mDevice; - private Context mTargetContext; - private String mTargetPackage; - - @Override - protected void setUp() throws Exception { - super.setUp(); - mDevice = UiDevice.getInstance(getInstrumentation()); - mTargetContext = getInstrumentation().getTargetContext(); - mTargetPackage = mTargetContext.getPackageName(); - } - - @Test - public void testSelectPictureInPicture_shouldNotCrash() throws Exception { - launchSpecialApps(); - final String titlePictureInPictureApp = - mTargetContext.getResources().getString(R.string.picture_in_picture_title); - - // select Picture-in-Picture - mDevice.findObject(new UiSelector().text(titlePictureInPictureApp)).click(); - - // Picture-in-picture settings page should launch and no crash - final UiObject actionBar = mDevice.findObject(new UiSelector().resourceId( - "com.android.settings:id/action_bar")); - final UiObject title = actionBar.getChild( - new UiSelector().className(TextView.class.getName())); - assertEquals(titlePictureInPictureApp, title.getText()); - } - - private void launchSpecialApps() throws Exception { - final Intent settingsIntent = new Intent(Intent.ACTION_MAIN) - .addCategory(Intent.CATEGORY_LAUNCHER) - .setPackage(mTargetPackage) - .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - getInstrumentation().getContext().startActivity(settingsIntent); - 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 titleSpecialApps = mTargetContext.getResources().getString( - R.string.special_access); - - try { - // scollbar may or may not be present, depending on how many recents app are there. If - // the page is scrollable, scroll to the bottom to show the special app access settings. - final UiScrollable settings = new UiScrollable( - new UiSelector().packageName(mTargetContext.getPackageName()).scrollable(true)); - settings.scrollTextIntoView(titleSpecialApps); - } catch (UiObjectNotFoundException e) { - // ignore - } - - mDevice.findObject(new UiSelector().text(titleSpecialApps)).click(); - } - -} diff --git a/tests/unit/src/com/android/settings/backup/BackupIntentTest.java b/tests/unit/src/com/android/settings/backup/BackupIntentTest.java index 0115c569ae..54e7451d8a 100644 --- a/tests/unit/src/com/android/settings/backup/BackupIntentTest.java +++ b/tests/unit/src/com/android/settings/backup/BackupIntentTest.java @@ -39,7 +39,7 @@ import java.util.List; public class BackupIntentTest { private static final String INTENT_PRIVACY_SETTINGS = "android.settings.PRIVACY_SETTINGS"; private static final String BACKUP_SETTINGS_ACTIVITY = - "com.android.settings.backup.UserBackupSettingsActivity"; + "com.android.settings.Settings$PrivacyDashboardActivity"; private Context mContext; diff --git a/tests/unit/src/com/android/settings/bluetooth/BluetoothDeviceDetailsRotationTest.java b/tests/unit/src/com/android/settings/bluetooth/BluetoothDeviceDetailsRotationTest.java deleted file mode 100644 index aec6dd22df..0000000000 --- a/tests/unit/src/com/android/settings/bluetooth/BluetoothDeviceDetailsRotationTest.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (C) 2017 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.bluetooth; - -import static org.mockito.Mockito.when; - -import android.app.Instrumentation; -import android.content.Context; -import android.content.Intent; -import android.os.Bundle; -import android.os.RemoteException; -import android.support.test.uiautomator.UiDevice; - -import androidx.test.InstrumentationRegistry; -import androidx.test.filters.SmallTest; -import androidx.test.runner.AndroidJUnit4; - -import com.android.settings.SettingsActivity; -import com.android.settings.core.SubSettingLauncher; -import com.android.settingslib.bluetooth.CachedBluetoothDevice; -import com.android.settingslib.bluetooth.LocalBluetoothManager; -import com.android.settingslib.core.instrumentation.Instrumentable; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Answers; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; - -@RunWith(AndroidJUnit4.class) -@SmallTest -public class BluetoothDeviceDetailsRotationTest { - private Context mContext; - private UiDevice mUiDevice; - private Instrumentation mInstrumentation; - - @Mock(answer = Answers.RETURNS_DEEP_STUBS) - private CachedBluetoothDevice mCachedDevice; - - @Mock(answer = Answers.RETURNS_DEEP_STUBS) - private LocalBluetoothManager mBluetoothManager; - - private String mDeviceAddress; - - @Before - public void setUp() throws Exception { - MockitoAnnotations.initMocks(this); - mContext = InstrumentationRegistry.getTargetContext(); - mUiDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()); - mInstrumentation = InstrumentationRegistry.getInstrumentation(); - - mDeviceAddress = "AA:BB:CC:DD:EE:FF"; - when(mCachedDevice.getAddress()).thenReturn(mDeviceAddress); - when(mCachedDevice.getName()).thenReturn("Mock Device"); - - BluetoothDeviceDetailsFragment.sTestDataFactory = - new BluetoothDeviceDetailsFragment.TestDataFactory() { - @Override - public CachedBluetoothDevice getDevice(String deviceAddress) { - return mCachedDevice; - } - - @Override - public LocalBluetoothManager getManager(Context context) { - return mBluetoothManager; - } - }; - } - - @Test - public void rotation() { - Intent intent = new Intent("android.settings.BLUETOOTH_SETTINGS"); - SettingsActivity activity = (SettingsActivity) mInstrumentation.startActivitySync(intent); - Bundle args = new Bundle(1); - args.putString(BluetoothDeviceDetailsFragment.KEY_DEVICE_ADDRESS, mDeviceAddress); - new SubSettingLauncher(activity) - .setDestination(BluetoothDeviceDetailsFragment.class.getName()) - .setTitleText("test") - .setArguments(args) - .setSourceMetricsCategory(Instrumentable.METRICS_CATEGORY_UNKNOWN) - .launch(); - try { - mUiDevice.setOrientationLeft(); - mUiDevice.setOrientationNatural(); - mUiDevice.setOrientationRight(); - mUiDevice.setOrientationNatural(); - } catch (RemoteException e) { - throw new RuntimeException(e); - } - } -} \ No newline at end of file diff --git a/tests/unit/src/com/android/settings/bluetooth/DevicePickerActivityTest.java b/tests/unit/src/com/android/settings/bluetooth/DevicePickerActivityTest.java deleted file mode 100644 index e531e0a974..0000000000 --- a/tests/unit/src/com/android/settings/bluetooth/DevicePickerActivityTest.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (C) 2017 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.bluetooth; - -import android.app.Instrumentation; -import android.content.Intent; - -import androidx.test.InstrumentationRegistry; -import androidx.test.filters.SmallTest; -import androidx.test.runner.AndroidJUnit4; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; - -@RunWith(AndroidJUnit4.class) -@SmallTest -public class DevicePickerActivityTest { - - private Instrumentation mInstrumentation; - - @Before - public void setUp() throws Exception { - mInstrumentation = InstrumentationRegistry.getInstrumentation(); - } - - @Test - public void startActivityNoCrash() { - mInstrumentation.startActivitySync( - new Intent("android.bluetooth.devicepicker.action.LAUNCH")); - // No crash - } -} diff --git a/tests/unit/src/com/android/settings/connecteddevice/ConnectedDeviceActivityTest.java b/tests/unit/src/com/android/settings/connecteddevice/ConnectedDeviceActivityTest.java deleted file mode 100644 index 2957c4cfdc..0000000000 --- a/tests/unit/src/com/android/settings/connecteddevice/ConnectedDeviceActivityTest.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (C) 2017 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.connecteddevice; - -import static com.google.common.truth.Truth.assertThat; - -import android.app.Instrumentation; -import android.content.Intent; -import android.content.pm.PackageManager; -import android.content.pm.ResolveInfo; -import android.text.TextUtils; - -import androidx.test.InstrumentationRegistry; -import androidx.test.filters.SmallTest; -import androidx.test.runner.AndroidJUnit4; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; - -import java.util.List; - -@RunWith(AndroidJUnit4.class) -@SmallTest -public class ConnectedDeviceActivityTest { - private static final String INTENT_ACTION = "android.intent.action.MAIN"; - private static final String CONNECTED_DEVICE_TITLE = "Connected devices"; - - private Instrumentation mInstrumentation; - - @Before - public void setUp() throws Exception { - mInstrumentation = InstrumentationRegistry.getInstrumentation(); - } - - @Test - public void queryConnectedDeviceActivity_onlyOneResponse() { - final PackageManager packageManager = mInstrumentation.getContext().getPackageManager(); - final Intent intent = new Intent(INTENT_ACTION); - - int count = 0; - final List resolveInfoList = packageManager.queryIntentActivities(intent, - PackageManager.GET_META_DATA); - for (ResolveInfo info : resolveInfoList) { - if (TextUtils.equals(info.activityInfo.loadLabel(packageManager).toString(), - CONNECTED_DEVICE_TITLE)) { - count++; - } - } - - assertThat(count).isEqualTo(1); - } - -} diff --git a/tests/unit/src/com/android/settings/dashboard/PreferenceThemeTest.java b/tests/unit/src/com/android/settings/dashboard/PreferenceThemeTest.java index 18a5e70f32..0ae5597f35 100644 --- a/tests/unit/src/com/android/settings/dashboard/PreferenceThemeTest.java +++ b/tests/unit/src/com/android/settings/dashboard/PreferenceThemeTest.java @@ -18,13 +18,9 @@ package com.android.settings.dashboard; import static androidx.test.espresso.Espresso.onView; import static androidx.test.espresso.assertion.ViewAssertions.doesNotExist; -import static androidx.test.espresso.assertion.ViewAssertions.matches; -import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; import static androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility; import static androidx.test.espresso.matcher.ViewMatchers.withId; -import static com.android.settings.dashboard.FirstIdViewMatcher.withFirstId; - import static org.hamcrest.Matchers.allOf; import android.app.Instrumentation; @@ -58,12 +54,6 @@ public class PreferenceThemeTest { } @Test - public void startPhoneStatus_preferenceIconSpaceReserved() throws InterruptedException { - launchPhoneStatus(); - onView(withFirstId(R.id.icon_frame)).check(matches(isDisplayed())); - } - - @Test public void startSetupWizardLockScreen_preferenceIconSpaceNotReserved() { launchSetupWizardLockScreen(); // Icons should not be shown, and the frame should not occupy extra space. @@ -72,14 +62,6 @@ public class PreferenceThemeTest { onView(withId(R.id.icon_container)).check(doesNotExist()); } - private void launchPhoneStatus() { - final Intent settingsIntent = new Intent("android.settings.DEVICE_INFO_SETTINGS") - .addCategory(Intent.CATEGORY_DEFAULT) - .setPackage(mTargetPackage) - .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - InstrumentationRegistry.getInstrumentation().startActivitySync(settingsIntent); - } - private void launchSetupWizardLockScreen() { final Intent settingsIntent = new Intent("com.android.settings.SETUP_LOCK_SCREEN") .addCategory(Intent.CATEGORY_DEFAULT) diff --git a/tests/unit/src/com/android/settings/datausage/MobileDataUsageActivityTest.java b/tests/unit/src/com/android/settings/datausage/MobileDataUsageActivityTest.java deleted file mode 100644 index 066d199714..0000000000 --- a/tests/unit/src/com/android/settings/datausage/MobileDataUsageActivityTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (C) 2017 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; - -import static junit.framework.Assert.assertEquals; - -import android.content.Context; -import android.content.Intent; -import android.content.pm.PackageManager; -import android.net.NetworkTemplate; -import android.telephony.SubscriptionManager; -import android.telephony.TelephonyManager; - -import androidx.test.InstrumentationRegistry; -import androidx.test.filters.SmallTest; -import androidx.test.runner.AndroidJUnit4; - -import org.junit.Test; -import org.junit.runner.RunWith; - -@RunWith(AndroidJUnit4.class) -@SmallTest -public class MobileDataUsageActivityTest { - private static final String TAG = "MobileDataUsageTest"; - @Test - public void test_mobileDataUsageIntent() { - final Context context = InstrumentationRegistry.getTargetContext(); - final PackageManager packageManager = context.getPackageManager(); - final int subId = SubscriptionManager.getDefaultSubscriptionId(); - final NetworkTemplate template = getNetworkTemplate(context, subId); - - Intent intent = new Intent(android.provider.Settings.ACTION_MOBILE_DATA_USAGE); - intent.putExtra(android.provider.Settings.EXTRA_NETWORK_TEMPLATE, template); - intent.putExtra(android.provider.Settings.EXTRA_SUB_ID, subId); - - assertEquals(packageManager.queryIntentActivities(intent, 0).size(), 1); - - context.startActivity(intent); - // Should exit gracefully without crashing. - } - - private NetworkTemplate getNetworkTemplate(Context context, int subId) { - TelephonyManager tm = (TelephonyManager) context - .getSystemService(Context.TELEPHONY_SERVICE); - NetworkTemplate mobileAll = NetworkTemplate.buildTemplateMobileAll( - tm.getSubscriberId(subId)); - return NetworkTemplate.normalize(mobileAll, - tm.getMergedSubscriberIds()); - } -} diff --git a/tests/unit/src/com/android/settings/datetime/timezone/model/TimeZoneDataTest.java b/tests/unit/src/com/android/settings/datetime/timezone/model/TimeZoneDataTest.java index 26595292f3..a04c08d37e 100644 --- a/tests/unit/src/com/android/settings/datetime/timezone/model/TimeZoneDataTest.java +++ b/tests/unit/src/com/android/settings/datetime/timezone/model/TimeZoneDataTest.java @@ -56,9 +56,6 @@ public class TimeZoneDataTest { */ assertThat(mTimeZoneData.lookupCountryCodesForZoneId("Europe/Simferopol").isEmpty()) .isTrue(); - // Metlakatla has the same time as Anchorage after 2015 - assertThat(mTimeZoneData.lookupCountryCodesForZoneId("America/Metlakatla").isEmpty()) - .isTrue(); assertThat(mTimeZoneData.lookupCountryCodesForZoneId("Europe/London").isEmpty()) .isFalse(); assertThat(mTimeZoneData.lookupCountryCodesForZoneId("America/Los_Angeles").isEmpty()) diff --git a/tests/unit/src/com/android/settings/deviceinfo/StorageDashboardFragmentTest.java b/tests/unit/src/com/android/settings/deviceinfo/StorageDashboardFragmentTest.java deleted file mode 100644 index a0053be5a3..0000000000 --- a/tests/unit/src/com/android/settings/deviceinfo/StorageDashboardFragmentTest.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.android.settings.deviceinfo; - -import static androidx.test.espresso.Espresso.onView; -import static androidx.test.espresso.action.ViewActions.click; -import static androidx.test.espresso.intent.Intents.intended; -import static androidx.test.espresso.intent.matcher.IntentMatchers.hasExtra; -import static androidx.test.espresso.matcher.ViewMatchers.withText; - -import static org.hamcrest.Matchers.containsString; -import static org.hamcrest.Matchers.equalTo; - -import androidx.test.espresso.intent.rule.IntentsTestRule; -import androidx.test.filters.SmallTest; - -import com.android.settings.R; -import com.android.settings.Settings.StorageDashboardActivity; -import com.android.settings.deletionhelper.AutomaticStorageManagerSettings; - -import org.junit.Rule; -import org.junit.Test; - -@SmallTest -public class StorageDashboardFragmentTest { - - public static final String EXTRA_KEY = ":settings:show_fragment"; - - @Rule - public IntentsTestRule mActivityRule = - new IntentsTestRule<>(StorageDashboardActivity.class, true, true); - - @Test - public void testStorageManagePreference_canClickTextView() throws InterruptedException { - // Click on the actual textbox instead of just somewhere in the preference - 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), - containsString(AutomaticStorageManagerSettings.class.getName()))); - - } -} diff --git a/tests/unit/src/com/android/settings/dream/DreamSettingsLaunchTest.java b/tests/unit/src/com/android/settings/dream/DreamSettingsLaunchTest.java deleted file mode 100644 index 6a2abd5455..0000000000 --- a/tests/unit/src/com/android/settings/dream/DreamSettingsLaunchTest.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2017 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.dream; - -import android.content.Context; -import android.content.Intent; -import android.provider.Settings; - -import androidx.test.InstrumentationRegistry; -import androidx.test.filters.SmallTest; -import androidx.test.runner.AndroidJUnit4; - -import org.junit.Test; -import org.junit.runner.RunWith; - -@RunWith(AndroidJUnit4.class) -@SmallTest -public class DreamSettingsLaunchTest { - - @Test - public void launchFromIntent_doesNotCrash() { - final Context context = InstrumentationRegistry.getTargetContext(); - Intent intent = new Intent(Settings.ACTION_DREAM_SETTINGS); - - context.startActivity(intent); - } -} diff --git a/tests/unit/src/com/android/settings/tests/DrawOverlayDetailsTest.java b/tests/unit/src/com/android/settings/tests/DrawOverlayDetailsTest.java deleted file mode 100644 index d450bf0cea..0000000000 --- a/tests/unit/src/com/android/settings/tests/DrawOverlayDetailsTest.java +++ /dev/null @@ -1,77 +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 static androidx.test.espresso.Espresso.onView; -import static androidx.test.espresso.Espresso.openActionBarOverflowOrOptionsMenu; -import static androidx.test.espresso.action.ViewActions.click; -import static androidx.test.espresso.assertion.ViewAssertions.matches; -import static androidx.test.espresso.matcher.ViewMatchers.isEnabled; -import static androidx.test.espresso.matcher.ViewMatchers.withText; - -import static org.hamcrest.core.IsNot.not; - -import android.app.Instrumentation; -import android.content.Context; -import android.content.Intent; -import android.content.pm.PackageManager; -import android.support.test.uiautomator.UiDevice; -import android.support.test.uiautomator.UiScrollable; -import android.support.test.uiautomator.UiSelector; - -import androidx.test.InstrumentationRegistry; -import androidx.test.filters.SmallTest; -import androidx.test.runner.AndroidJUnit4; - -import com.android.settings.R; - -import org.junit.Test; -import org.junit.runner.RunWith; - -@RunWith(AndroidJUnit4.class) -@SmallTest -public class DrawOverlayDetailsTest { - private final static String PACKAGE_SYSTEM_UI = "com.android.systemui"; - - @Test - public void testSystemUiDrawOverlayDetails_Disabled() throws Exception{ - Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation(); - instrumentation.startActivitySync(new Intent(android.provider.Settings - .ACTION_MANAGE_OVERLAY_PERMISSION)); - - final Context targetContext = instrumentation.getTargetContext(); - - final PackageManager packageManager = targetContext.getPackageManager(); - final String appName = (String) packageManager.getApplicationLabel(packageManager - .getApplicationInfo(PACKAGE_SYSTEM_UI, PackageManager.GET_META_DATA)); - - final UiDevice device = UiDevice.getInstance(instrumentation); - device.waitForIdle(); - - openActionBarOverflowOrOptionsMenu(targetContext); - onView(withText(targetContext.getString(R.string.menu_show_system))).perform(click()); - device.waitForIdle(); - - final UiScrollable settings = new UiScrollable( - new UiSelector().packageName(targetContext.getPackageName()).scrollable(true)); - settings.scrollTextIntoView(appName); - onView(withText(appName)).perform(click()); - onView(withText(targetContext.getString(R.string.permit_draw_overlay))).check(matches - (not(isEnabled()))); - } - -} diff --git a/tests/unit/src/com/android/settings/tests/KeepOnScreenTest.java b/tests/unit/src/com/android/settings/tests/KeepOnScreenTest.java deleted file mode 100644 index b930ffb1f6..0000000000 --- a/tests/unit/src/com/android/settings/tests/KeepOnScreenTest.java +++ /dev/null @@ -1,72 +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 static androidx.test.espresso.Espresso.onView; -import static androidx.test.espresso.action.ViewActions.click; -import static androidx.test.espresso.matcher.ViewMatchers.withText; - -import static junit.framework.Assert.assertEquals; - -import android.app.Instrumentation; -import android.content.Context; -import android.content.Intent; -import android.os.BatteryManager; -import android.provider.Settings; - -import androidx.test.InstrumentationRegistry; -import androidx.test.filters.SmallTest; -import androidx.test.runner.AndroidJUnit4; - -import com.android.settings.R; - -import org.junit.Test; -import org.junit.runner.RunWith; - -@RunWith(AndroidJUnit4.class) -@SmallTest -public class KeepOnScreenTest { - private static int EXPECTED_FLAG = BatteryManager.BATTERY_PLUGGED_AC - | BatteryManager.BATTERY_PLUGGED_USB | BatteryManager.BATTERY_PLUGGED_WIRELESS; - - @Test - public void testStayAwake_turnOn_StayAwakeWhileWirelessCharging() throws Exception{ - Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation(); - instrumentation.startActivitySync(new Intent(android.provider.Settings - .ACTION_APPLICATION_DEVELOPMENT_SETTINGS)); - - final Context targetContext = instrumentation.getTargetContext(); - final int prevFlag = Settings.Global.getInt(targetContext.getContentResolver(), Settings - .Global.STAY_ON_WHILE_PLUGGED_IN); - - // Turn on "Stay Awake" if needed - if (prevFlag == 0) { - onView(withText(R.string.keep_screen_on)).perform(click()); - } - - final int currentFlag = Settings.Global.getInt(targetContext.getContentResolver(), Settings - .Global.STAY_ON_WHILE_PLUGGED_IN); - - assertEquals(EXPECTED_FLAG, currentFlag); - - // Since this app doesn't have permission(and shouldn't have) to change global setting, we - // can only tearDown in this way - if (prevFlag != currentFlag) { - onView(withText(R.string.keep_screen_on)).perform(click()); - } - } -} diff --git a/tests/unit/src/com/android/settings/tests/PrivateVolumeSettingsTest.java b/tests/unit/src/com/android/settings/tests/PrivateVolumeSettingsTest.java deleted file mode 100644 index 2760a0782a..0000000000 --- a/tests/unit/src/com/android/settings/tests/PrivateVolumeSettingsTest.java +++ /dev/null @@ -1,42 +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 static androidx.test.espresso.Espresso.onView; -import static androidx.test.espresso.assertion.ViewAssertions.doesNotExist; -import static androidx.test.espresso.matcher.ViewMatchers.withText; - -import android.app.Instrumentation; -import android.content.Intent; - -import androidx.test.InstrumentationRegistry; -import androidx.test.filters.SmallTest; -import androidx.test.runner.AndroidJUnit4; - -import org.junit.Test; -import org.junit.runner.RunWith; - -@RunWith(AndroidJUnit4.class) -@SmallTest -public class PrivateVolumeSettingsTest { - @Test - public void test_ManageStorageNotShown() { - Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation(); - instrumentation.startActivitySync( - new Intent(android.provider.Settings.ACTION_INTERNAL_STORAGE_SETTINGS)); - onView(withText(com.android.settings.R.string.storage_menu_manage)).check(doesNotExist()); - } -} \ No newline at end of file diff --git a/tests/unit/src/com/android/settings/tests/SettingsRestoreAfterCloseTest.java b/tests/unit/src/com/android/settings/tests/SettingsRestoreAfterCloseTest.java deleted file mode 100644 index 3c6caf7864..0000000000 --- a/tests/unit/src/com/android/settings/tests/SettingsRestoreAfterCloseTest.java +++ /dev/null @@ -1,84 +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.ActivityManager; -import android.content.Context; -import android.content.Intent; -import android.provider.Settings; -import android.support.test.uiautomator.By; -import android.support.test.uiautomator.UiDevice; -import android.support.test.uiautomator.Until; - -import androidx.test.InstrumentationRegistry; -import androidx.test.filters.SmallTest; -import androidx.test.runner.AndroidJUnit4; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; - -@RunWith(AndroidJUnit4.class) -@SmallTest -public class SettingsRestoreAfterCloseTest { - private static final String PACKAGE_SETTINGS = "com.android.settings"; - private static final int TIME_OUT = 2000; - - private boolean mAlwaysFinish; - - @Before - public void setUp() throws Exception { - // To make sure when we press home button, the activity will be destroyed by OS - Context context = InstrumentationRegistry.getContext(); - mAlwaysFinish = Settings.Global.getInt( - context.getContentResolver(), Settings.Global - .ALWAYS_FINISH_ACTIVITIES, 0) - != 0; - - ActivityManager.getService().setAlwaysFinish(true); - } - - @After - public void tearDown() throws Exception { - ActivityManager.getService().setAlwaysFinish(mAlwaysFinish); - } - - @Test - public void testRtlStability_AppCloseAndReOpen_shouldNotCrash() throws Exception { - - final UiDevice uiDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation - ()); - uiDevice.pressHome(); - - // Open the settings app - startSettingsMainActivity(uiDevice); - - // Press home button - uiDevice.pressHome(); - final String launcherPackage = uiDevice.getLauncherPackageName(); - uiDevice.wait(Until.hasObject(By.pkg(launcherPackage).depth(0)), TIME_OUT); - - // Open the settings again - startSettingsMainActivity(uiDevice); - } - - private void startSettingsMainActivity(UiDevice uiDevice) { - Context context = InstrumentationRegistry.getContext(); - context.startActivity(new Intent(android.provider.Settings.ACTION_SETTINGS)); - uiDevice.wait(Until.hasObject(By.pkg(PACKAGE_SETTINGS).depth(0)), TIME_OUT); - } -} diff --git a/tests/unit/src/com/android/settings/users/UserSettingsTest.java b/tests/unit/src/com/android/settings/users/UserSettingsTest.java deleted file mode 100644 index 93f62f39a1..0000000000 --- a/tests/unit/src/com/android/settings/users/UserSettingsTest.java +++ /dev/null @@ -1,140 +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.users; - -import static com.google.common.truth.Truth.assertThat; - -import android.content.Context; -import android.content.Intent; -import android.support.test.uiautomator.UiDevice; -import android.support.test.uiautomator.UiObject; -import android.support.test.uiautomator.UiObjectNotFoundException; -import android.support.test.uiautomator.UiScrollable; -import android.support.test.uiautomator.UiSelector; - -import androidx.test.InstrumentationRegistry; -import androidx.test.filters.SmallTest; -import androidx.test.runner.AndroidJUnit4; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; - -@RunWith(AndroidJUnit4.class) -@SmallTest -public class UserSettingsTest { - - private static final String SYSTEM = "System"; - private static final String ADVANCED = "Advanced"; - private static final String USERS = "Multiple users"; - private static final String EMERGNENCY_INFO = "Emergency information"; - private static final String ADD_USERS_WHEN_LOCKED = "Add users"; - private static final String SWITCH_USER_BUTTON = "com.android.systemui:id/multi_user_switch"; - private static final String SETTINGS_BUTTON = "com.android.systemui:id/settings_button"; - private static final String PRIMARY_USER = "Owner"; - private static final String GUEST_USER = "Guest"; - private static final String ADD_GUEST = "Add guest"; - private static final String CONTINUE = "Yes, continue"; - - private UiDevice mDevice; - private Context mContext; - private String mTargetPackage; - - @Before - public void setUp() { - mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()); - mContext = InstrumentationRegistry.getTargetContext(); - mTargetPackage = mContext.getPackageName(); - } - - @Test - public void testEmergencyInfoNotExists() throws Exception { - launchUserSettings(); - UiObject emergencyInfoPreference = - mDevice.findObject(new UiSelector().text(EMERGNENCY_INFO)); - - assertThat(emergencyInfoPreference.exists()).isFalse(); - } - - @Test - public void testAddUsersWhenLockedNotExists() throws Exception { - launchUserSettings(); - UiObject addUsersPreference = - mDevice.findObject(new UiSelector().text(ADD_USERS_WHEN_LOCKED)); - assertThat(addUsersPreference.exists()).isFalse(); - } - - @Test - public void testUsersExistsOnSecondaryUser() throws Exception { - // switch to guest user - switchToOrCreateGuest(); - // launch settings (launch from intent doesn't work, hence launch from quick settings) - mDevice.openQuickSettings(); - mDevice.findObject(new UiSelector().resourceId(SETTINGS_BUTTON)).click(); - // launch system settings and expand whole screen - final UiScrollable settings = new UiScrollable( - new UiSelector().packageName(mTargetPackage).scrollable(true)); - final String titleSystem = SYSTEM; - settings.scrollTextIntoView(titleSystem); - mDevice.findObject(new UiSelector().text(titleSystem)).click(); - mDevice.findObject(new UiSelector().text(ADVANCED)).click(); - - final boolean hasUsersSettings = mDevice.findObject(new UiSelector().text(USERS)).exists(); - - // switch back to primary user - mDevice.openQuickSettings(); - mDevice.findObject(new UiSelector().resourceId(SWITCH_USER_BUTTON)).click(); - mDevice.findObject(new UiSelector().text(PRIMARY_USER)).click(); - - assertThat(hasUsersSettings).isTrue(); - } - - private void launchSettings() { - Intent settingsIntent = new Intent(Intent.ACTION_MAIN) - .addCategory(Intent.CATEGORY_LAUNCHER) - .setPackage(mTargetPackage) - .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - mContext.startActivity(settingsIntent); - } - - private void launchUserSettings() throws Exception { - launchSettings(); - final UiScrollable settings = new UiScrollable( - new UiSelector().packageName(mTargetPackage).scrollable(true)); - final String titleSystem = SYSTEM; - settings.scrollTextIntoView(titleSystem); - mDevice.findObject(new UiSelector().text(titleSystem)).click(); - mDevice.findObject(new UiSelector().text(ADVANCED)).click(); - mDevice.findObject(new UiSelector().text(USERS)).click(); - } - - private void switchToOrCreateGuest() throws UiObjectNotFoundException { - mDevice.openQuickSettings(); - mDevice.findObject(new UiSelector().resourceId(SWITCH_USER_BUTTON)).click(); - // if no existing guest user, select "Add guest", otherwise select "Guest" - final UiObject addGuest = mDevice.findObject(new UiSelector().text(ADD_GUEST)); - if (addGuest.exists()) { - addGuest.click(); - mDevice.waitForIdle(); - mDevice.pressBack(); - } else { - mDevice.findObject(new UiSelector().text(GUEST_USER)).click(); - mDevice.waitForIdle(); - mDevice.findObject(new UiSelector().text(CONTINUE)).click(); - mDevice.waitForIdle(); - } - } -} diff --git a/tests/unit/src/com/android/settings/wifi/tether/WifiTetherSettingsTest.java b/tests/unit/src/com/android/settings/wifi/tether/WifiTetherSettingsTest.java index cb586e4343..2de66110c5 100644 --- a/tests/unit/src/com/android/settings/wifi/tether/WifiTetherSettingsTest.java +++ b/tests/unit/src/com/android/settings/wifi/tether/WifiTetherSettingsTest.java @@ -56,7 +56,8 @@ public class WifiTetherSettingsTest { mTetherActivityIntent = new Intent() .setClassName(mInstrumentation.getTargetContext().getPackageName(), Settings.TetherSettingsActivity.class.getName()) - .setPackage(mInstrumentation.getTargetContext().getPackageName()); + .setPackage(mInstrumentation.getTargetContext().getPackageName()) + .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); } @After @@ -69,7 +70,6 @@ public class WifiTetherSettingsTest { launchWifiTetherActivity(); onView(withText("Hotspot name")).check(matches(isDisplayed())); onView(withText("Hotspot password")).check(matches(isDisplayed())); - onView(withText("AP Band")).check(matches(isDisplayed())); } private void launchWifiTetherActivity() { -- 2.11.0