+++ /dev/null
-/*
- * 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
- }
-}
+++ /dev/null
-/*
- * 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;
- }
- }
-}
+++ /dev/null
-/*
- * 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());
- }
- }
-}
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;
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;
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 {
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;
- }
-
-
}
+++ /dev/null
-/*
- * 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<Settings> {
-
- 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<ResolveInfo> 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<ResolveInfo> 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);
- }
-
-}
import android.app.Instrumentation;
import android.os.Bundle;
+
import android.provider.Settings;
import android.widget.CompoundButton;
}
@Test
- public void lockScreenPreference_defaultBeforeDialogShown_isOff() {
- setDialogShown(false);
- setOnLockscreen(null);
- startFragment();
- assertLockscreenSwitchIsCheckedIs(false);
- }
-
- @Test
public void lockScreenPreference_setOnBeforeDialogShown_isOn() {
setDialogShown(false);
setOnLockscreen(true);
assertLockscreenSwitchIsCheckedIs(true);
}
- @Test
- public void lockScreenPreference_setOffAfterDialogShown_isOn() {
- setDialogShown(true);
- setOnLockscreen(false);
- startFragment();
- assertLockscreenSwitchIsCheckedIs(false);
- }
-
private void startFragment() {
mInstrumentation.runOnMainSync(() -> {
new SubSettingLauncher(mActivity)
+++ /dev/null
-/*
- * 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();
- }
-
-}
+++ /dev/null
-/*
- * 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()));
- }
-}
+++ /dev/null
-/*
- * 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();
- }
-
-}
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;
+++ /dev/null
-/*
- * 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
+++ /dev/null
-/*
- * 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
- }
-}
+++ /dev/null
-/*
- * 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<ResolveInfo> 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);
- }
-
-}
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;
}
@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.
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)
+++ /dev/null
-/*
- * 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());
- }
-}
*/
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())
+++ /dev/null
-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<StorageDashboardActivity> 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())));
-
- }
-}
+++ /dev/null
-/*
- * 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);
- }
-}
+++ /dev/null
-/*
- * 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())));
- }
-
-}
+++ /dev/null
-/*
- * 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());
- }
- }
-}
+++ /dev/null
-/*
- * 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
+++ /dev/null
-/*
- * 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);
- }
-}
+++ /dev/null
-/*
- * 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();
- }
- }
-}
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
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() {