Remove old code relating to SystemSettings not used in new IA.

- remove activity alias: DevelopmentSettingsDashboardAlias,
DateTimeDashboardAlias, AboutDeviceDashboardAlias,
BackupResetDashboardAlias, EnterprisePrivacyDashboardAlias, and
AccessibilityDashboardAlias and updated the corresponding target
activities with the alias metadata.

- remove InputMethodAndLanguageSettingsActivity and
GestureSettingsActivity and the associated xml.

Bug: 35764802
Test: make RunSettingsRoboTests
Change-Id: I7d4922f8dfaac40e8ad077a68008185cd9fe3304
This commit is contained in:
Doris Ling
2017-02-28 17:32:36 -08:00
parent b567ff46c3
commit d299b03f28
18 changed files with 77 additions and 965 deletions

View File

@@ -1,195 +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.gesture;
import android.content.Context;
import android.content.Intent;
import android.provider.Settings.Secure;
import android.support.test.filters.MediumTest;
import android.support.test.uiautomator.UiDevice;
import android.support.test.uiautomator.UiObject;
import android.support.test.uiautomator.UiSelector;
import android.support.test.uiautomator.UiScrollable;
import android.test.InstrumentationTestCase;
import android.util.Log;
import android.widget.RelativeLayout;
import android.widget.Switch;
import com.android.settings.R;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import org.junit.Test;
/**
* Test for Gesture preferences.
*/
@MediumTest
public class GestureSettingsTest extends InstrumentationTestCase {
private static final String TAG = "GestureSettingsTest";
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 testAmbientDisplaySwitchPreference() throws Exception {
launchSettings();
UiObject dozeSwitch = getDozeSwitch();
assertNotNull(dozeSwitch);
assertTrue(dozeSwitch.exists());
assertToggleStateMatchesSettingValue(dozeSwitch, Secure.DOZE_ENABLED, 1, 1);
}
@Test
public void testGestureSettingsExists() throws Exception {
launchMoves();
UiObject titleObj = mDevice.findObject(new UiSelector().text(
mTargetContext.getResources().getString(R.string.gesture_preference_title)));
assertNotNull(titleObj);
assertTrue(titleObj.exists());
}
@Test
public void testCameraDoubleTapToggle() throws Exception {
assertSwitchToggle(mTargetContext.getResources().getString(
R.string.double_tap_power_for_camera_title),
Secure.CAMERA_DOUBLE_TAP_POWER_GESTURE_DISABLED, 0, 0);
}
@Test
public void testCameraDoubleTwistToggle() throws Exception {
assertSwitchToggle(mTargetContext.getResources().getString(
R.string.double_twist_for_camera_mode_title),
Secure.CAMERA_DOUBLE_TWIST_TO_FLIP_ENABLED, 1, 1);
}
@Test
public void testFingerprintSwipeToggle() throws Exception {
assertSwitchToggle(mTargetContext.getResources().getString(
R.string.fingerprint_swipe_for_notifications_title),
Secure.SYSTEM_NAVIGATION_KEYS_ENABLED, 0, 1);
}
@Test
public void testDozeDoubleTapToggle() throws Exception {
assertSwitchToggle(mTargetContext.getResources().getString(
R.string.ambient_display_title),
Secure.DOZE_PULSE_ON_DOUBLE_TAP, 1, 1);
}
@Test
public void testDozePickupToggle() throws Exception {
assertSwitchToggle(mTargetContext.getResources().getString(
R.string.ambient_display_pickup_title),
Secure.DOZE_PULSE_ON_PICK_UP, 1, 1);
}
private void launchSettings() {
Intent settingsIntent = new Intent(Intent.ACTION_MAIN)
.addCategory(Intent.CATEGORY_LAUNCHER)
.setPackage(mTargetPackage)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
getInstrumentation().getContext().startActivity(settingsIntent);
}
private void launchMoves() throws Exception {
launchSettings();
UiScrollable settings = new UiScrollable(
new UiSelector().packageName(mTargetPackage).scrollable(true));
String titleMoves =
mTargetContext.getResources().getString(R.string.gesture_preference_title);
settings.scrollTextIntoView(titleMoves);
mDevice.findObject(new UiSelector().text(titleMoves)).click();
}
private void navigateToMovesSetting(String title) throws Exception {
launchMoves();
UiScrollable moves = new UiScrollable(
new UiSelector().packageName(mTargetPackage).scrollable(true));
moves.scrollTextIntoView(title);
}
private UiScrollable navigateToAmbientDisplay() throws Exception {
UiScrollable settings = new UiScrollable(
new UiSelector().packageName(mTargetPackage).scrollable(true));
String titleDisplay =
mTargetContext.getResources().getString(R.string.display_settings_title);
settings.scrollTextIntoView(titleDisplay);
mDevice.findObject(new UiSelector().text(titleDisplay)).click();
settings.scrollTextIntoView(mTargetContext.getResources().getString(R.string.doze_title));
return settings;
}
private UiObject getGestureSwitch(String title) throws Exception {
UiObject titleView = mDevice.findObject(new UiSelector().text(title));
UiObject gestureSwitch =
titleView.getFromParent(new UiSelector().className(Switch.class.getName()));
assertNotNull(gestureSwitch);
assertTrue(gestureSwitch.exists());
return gestureSwitch;
}
private UiObject getDozeSwitch() throws Exception {
UiScrollable settings = navigateToAmbientDisplay();
UiObject dozeSwitch = null;
UiSelector relativeLayoutSelector =
new UiSelector().className(RelativeLayout.class.getName());
String titleDoze = mTargetContext.getResources().getString(R.string.doze_title);
for (int i = 0; i <= settings.getChildCount(relativeLayoutSelector); i++) {
UiObject relativeLayout = settings.getChild(relativeLayoutSelector.instance(i));
if (relativeLayout.getChildCount() != 2) {
continue;
}
UiObject obj1 = relativeLayout.getChild(new UiSelector().index(0));
if (obj1.getText() == titleDoze) {
return relativeLayout.getFromParent(
new UiSelector().className(Switch.class.getName()));
}
}
return null;
}
private void assertSwitchToggle(String title, String key, int defaultVal, int enabledVal)
throws Exception {
navigateToMovesSetting(title);
assertToggleStateMatchesSettingValue(getGestureSwitch(title), key, defaultVal, enabledVal);
}
private void assertToggleStateMatchesSettingValue (
UiObject testSwitch, String key, int defaultVal, int enabledVal) throws Exception {
// check initial state
int currentValue = Secure.getInt(mTargetContext.getContentResolver(), key, defaultVal);
boolean enabled = currentValue == enabledVal;
assertEquals(enabled, testSwitch.isChecked());
// toggle the preference
testSwitch.click();
assertEquals(!enabled, testSwitch.isChecked());
int newValue = currentValue == 1 ? 0 : 1;
assertEquals(newValue, Secure.getInt(mTargetContext.getContentResolver(), key, defaultVal));
}
}

View File

@@ -3,6 +3,5 @@ com.android.settings.language.LanguageAndRegionSettings
com.android.settings.notification.ZenModePrioritySettings
com.android.settings.inputmethod.InputAndGestureSettings
com.android.settings.accounts.AccountDetailDashboardFragment
com.android.settings.gestures.GestureSettings
com.android.settings.fuelgauge.PowerUsageDetail
com.android.settings.deviceinfo.StorageProfileFragment

View File

@@ -58,9 +58,9 @@ import com.android.settings.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
import com.android.settings.accessibility.AccessibilitySettings;
import com.android.settings.inputmethod.AvailableVirtualKeyboardFragment;
import com.android.settings.inputmethod.InputMethodAndLanguageSettings;
import com.android.settings.inputmethod.PhysicalKeyboardFragment;
import com.android.settings.inputmethod.VirtualKeyboardFragment;
import com.android.settings.language.LanguageAndInputSettings;
import com.android.settings.print.PrintSettingsFragment;
import com.android.settings.testutils.shadow.ShadowActivityWithLoadManager;
import com.android.settings.testutils.shadow.ShadowContextImplWithRegisterReceiver;
@@ -417,7 +417,7 @@ public class DynamicIndexableContentMonitorTest {
final ContentObserver observer = extractContentObserver(UserDictionary.Words.CONTENT_URI);
assertThat(observer).isNotNull();
verifyRebuildIndexing(InputMethodAndLanguageSettings.class);
verifyRebuildIndexing(LanguageAndInputSettings.class);
/*
* When user dictionary content is changed, rebuild indexing happens.
@@ -426,7 +426,7 @@ public class DynamicIndexableContentMonitorTest {
observer.onChange(false /* selfChange */, UserDictionary.Words.CONTENT_URI);
verifyRebuildIndexing(InputMethodAndLanguageSettings.class);
verifyRebuildIndexing(LanguageAndInputSettings.class);
}
/*

View File

@@ -56,40 +56,40 @@ public class XmlParserUtilTest {
@Test
public void testDataTitleValid_ReturnsPreferenceTitle() {
XmlResourceParser parser = getChildByType(R.xml.gesture_settings,
"com.android.settings.gestures.GesturePreference");
XmlResourceParser parser = getChildByType(R.xml.ia_display_settings,
"com.android.settings.TimeoutListPreference");
final AttributeSet attrs = Xml.asAttributeSet(parser);
String title = XmlParserUtils.getDataTitle(mContext, attrs);
String expTitle = mContext.getString(R.string.assist_gesture_title);
String expTitle = mContext.getString(R.string.screen_timeout);
assertThat(title).isEqualTo(expTitle);
}
@Test
public void testDataKeywordsValid_ReturnsPreferenceKeywords() {
XmlResourceParser parser = getParentPrimedParser(R.xml.gesture_settings);
XmlResourceParser parser = getParentPrimedParser(R.xml.ia_display_settings);
final AttributeSet attrs = Xml.asAttributeSet(parser);
String keywords = XmlParserUtils.getDataKeywords(mContext, attrs);
String expKeywords = mContext.getString(R.string.keywords_gesture);
String expKeywords = mContext.getString(R.string.keywords_display);
assertThat(keywords).isEqualTo(expKeywords);
}
@Test
public void testDataKeyValid_ReturnsPreferenceKey() {
XmlResourceParser parser = getChildByType(R.xml.gesture_settings,
"com.android.settings.gestures.GesturePreference");
XmlResourceParser parser = getChildByType(R.xml.ia_display_settings,
"com.android.settings.TimeoutListPreference");
final AttributeSet attrs = Xml.asAttributeSet(parser);
String key = XmlParserUtils.getDataKey(mContext, attrs);
String expKey = "gesture_assist";
String expKey = "screen_timeout";
assertThat(key).isEqualTo(expKey);
}
@Test
public void testDataSummaryValid_ReturnsPreferenceSummary() {
XmlResourceParser parser = getChildByType(R.xml.gesture_settings,
"com.android.settings.gestures.GesturePreference");
XmlResourceParser parser = getChildByType(R.xml.ia_display_settings,
"com.android.settings.TimeoutListPreference");
final AttributeSet attrs = Xml.asAttributeSet(parser);
String summary = XmlParserUtils.getDataSummary(mContext, attrs);
String expSummary = mContext.getString(R.string.assist_gesture_summary);
String expSummary = mContext.getString(R.string.screen_timeout_summary);
assertThat(summary).isEqualTo(expSummary);
}
@@ -128,7 +128,7 @@ public class XmlParserUtilTest {
@Test
public void testDataKeyInvalid_ReturnsNull() {
XmlResourceParser parser = getParentPrimedParser(R.xml.gesture_settings);
XmlResourceParser parser = getParentPrimedParser(R.xml.ia_display_settings);
final AttributeSet attrs = Xml.asAttributeSet(parser);
String key = XmlParserUtils.getDataKey(mContext, attrs);
assertThat(key).isNull();
@@ -136,7 +136,7 @@ public class XmlParserUtilTest {
@Test
public void testDataSummaryInvalid_ReturnsNull() {
XmlResourceParser parser = getParentPrimedParser(R.xml.gesture_settings);
XmlResourceParser parser = getParentPrimedParser(R.xml.ia_display_settings);
final AttributeSet attrs = Xml.asAttributeSet(parser);
String summary = XmlParserUtils.getDataSummary(mContext, attrs);
assertThat(summary).isNull();
@@ -144,7 +144,7 @@ public class XmlParserUtilTest {
@Test
public void testDataSummaryOffInvalid_ReturnsNull() {
XmlResourceParser parser = getParentPrimedParser(R.xml.gesture_settings);
XmlResourceParser parser = getParentPrimedParser(R.xml.ia_display_settings);
final AttributeSet attrs = Xml.asAttributeSet(parser);
String summaryOff = XmlParserUtils.getDataSummaryOff(mContext, attrs);
assertThat(summaryOff).isNull();
@@ -152,7 +152,7 @@ public class XmlParserUtilTest {
@Test
public void testDataEntriesInvalid_ReturnsNull() {
XmlResourceParser parser = getParentPrimedParser(R.xml.gesture_settings);
XmlResourceParser parser = getParentPrimedParser(R.xml.ia_display_settings);
final AttributeSet attrs = Xml.asAttributeSet(parser);
String entries = XmlParserUtils.getDataEntries(mContext, attrs);
assertThat(entries).isNull();

View File

@@ -29,7 +29,7 @@ import com.android.settings.SettingsRobolectricTestRunner;
import com.android.settings.SubSettings;
import com.android.settings.TestConfig;
import com.android.settings.dashboard.SiteMapManager;
import com.android.settings.gestures.GestureSettings;
import com.android.settings.gestures.SwipeToNotificationSettings;
import com.android.settings.search2.ResultPayload.PayloadType;
import org.junit.Before;
@@ -155,7 +155,7 @@ public class CursorToSearchResultConverterTest {
TITLES[0], // Title
SUMMARY, // Summary on
SUMMARY, // summary off
GestureSettings.class.getName(),
SwipeToNotificationSettings.class.getName(),
BLANK, // screen title
null, // icon
BLANK, // action
@@ -226,7 +226,7 @@ public class CursorToSearchResultConverterTest {
TITLES[0], // Title
SUMMARY, // Summary on
SUMMARY, // summary off
GestureSettings.class.getName(),
SwipeToNotificationSettings.class.getName(),
BLANK, // screen title
null, // icon
BLANK, // action

View File

@@ -205,25 +205,25 @@ public class DatabaseIndexingManagerTest {
@Test
public void testAddResource_RowsInserted() {
SearchIndexableResource resource = getFakeResource(R.xml.gesture_settings);
SearchIndexableResource resource = getFakeResource(R.xml.ia_display_settings);
mManager.indexOneSearchIndexableData(mDb, localeStr, resource,
new HashMap<>());
Cursor cursor = mDb.rawQuery("SELECT * FROM prefs_index", null);
assertThat(cursor.getCount()).isEqualTo(7);
assertThat(cursor.getCount()).isEqualTo(16);
}
@Test
public void testAddResourceWithNIKs_RowsInsertedDisabled() {
SearchIndexableResource resource = getFakeResource(R.xml.gesture_settings);
// Only add 2 of 6 items to be disabled.
String[] keys = {"gesture_double_tap_power", "gesture_swipe_down_fingerprint"};
SearchIndexableResource resource = getFakeResource(R.xml.ia_display_settings);
// Only add 2 of 16 items to be disabled.
String[] keys = {"brightness", "wallpaper"};
Map<String, List<String>> niks = getNonIndexableKeys(keys);
mManager.indexOneSearchIndexableData(mDb, localeStr, resource, niks);
Cursor cursor = mDb.rawQuery("SELECT * FROM prefs_index WHERE enabled = 0", null);
assertThat(cursor.getCount()).isEqualTo(2);
cursor = mDb.rawQuery("SELECT * FROM prefs_index WHERE enabled = 1", null);
assertThat(cursor.getCount()).isEqualTo(5);
assertThat(cursor.getCount()).isEqualTo(14);
}
@Test
@@ -306,7 +306,7 @@ public class DatabaseIndexingManagerTest {
@Test
public void testAddResourceCustomSetting_RowsMatch() {
SearchIndexableResource resource = getFakeResource(R.xml.gesture_settings);
SearchIndexableResource resource = getFakeResource(R.xml.swipe_to_notification_settings);
mManager.indexOneSearchIndexableData(mDb, localeStr, resource,
new HashMap<>());
final String prefTitle =
@@ -339,7 +339,7 @@ public class DatabaseIndexingManagerTest {
assertThat(cursor.getString(9)).isEmpty();
// Screen Title
assertThat(cursor.getString(10)).isEqualTo(
mContext.getString(R.string.gesture_preference_title));
mContext.getString(R.string.fingerprint_swipe_for_notifications_title));
// Class Name
assertThat(cursor.getString(11)).isEqualTo(className);
// Icon
@@ -477,7 +477,7 @@ public class DatabaseIndexingManagerTest {
@Test
public void testResourceProvider_RowInserted() {
SearchIndexableResource resource = getFakeResource(R.xml.gesture_settings);
SearchIndexableResource resource = getFakeResource(R.xml.swipe_to_notification_settings);
resource.xmlResId = 0;
resource.className = "com.android.settings.display.ScreenZoomSettings";
@@ -489,7 +489,7 @@ public class DatabaseIndexingManagerTest {
@Test
public void testResourceProvider_Matches() {
SearchIndexableResource resource = getFakeResource(R.xml.gesture_settings);
SearchIndexableResource resource = getFakeResource(R.xml.swipe_to_notification_settings);
resource.xmlResId = 0;
resource.className = "com.android.settings.display.ScreenZoomSettings";