release-request-dbb5053c-c8af-4c07-a295-d7d7b281ce3f-for-git_pi-release-4306414 snap-temp-L16000000097876522
Change-Id: I7f77c46220b757b41781c7626b495faa6cf19a0c
This commit is contained in:
@@ -5218,9 +5218,10 @@
|
||||
<string name="credentials_not_erased">Credential storage couldn\u2019t be erased.</string>
|
||||
<!-- Toast message [CHAR LIMIT=30] -->
|
||||
<string name="credentials_enabled">Credential storage is enabled.</string>
|
||||
<!-- Description of dialog to explain that a lock screen password is required to use credential storage [CHAR LIMIT=NONE] -->
|
||||
<string name="credentials_configure_lock_screen_hint">You need to set a lock screen PIN or password before you can use credential storage.</string>
|
||||
|
||||
<!-- This string is in a dialog, and the dialog shows up on a device that's managed by a user's company. It lets the user know that they need to have a secure lock screen (PIN, password, or pattern) before they can use credential storage [CHAR LIMIT=NONE] -->
|
||||
<string name="credentials_configure_lock_screen_hint">Before you can use credential storage, your device need to have a secure lock screen</string>
|
||||
<!-- This string is for the content of the button that leads user to lock screen settings [CHAR LIMIT=20] -->
|
||||
<string name="credentials_configure_lock_screen_button">SET LOCK</string>
|
||||
<!-- Title of Usage Access preference item [CHAR LIMIT=30] -->
|
||||
<string name="usage_access_title">Apps with usage access</string>
|
||||
|
||||
|
||||
@@ -16,7 +16,9 @@
|
||||
|
||||
package com.android.settings.fuelgauge;
|
||||
|
||||
import android.annotation.UserIdInt;
|
||||
import android.app.Activity;
|
||||
import android.app.ActivityManager;
|
||||
import android.app.LoaderManager;
|
||||
import android.app.admin.DevicePolicyManager;
|
||||
import android.content.Context;
|
||||
@@ -152,7 +154,14 @@ public class AdvancedPowerUsageDetail extends DashboardFragment implements
|
||||
|
||||
caller.startPreferencePanelAsUser(fragment, AdvancedPowerUsageDetail.class.getName(), args,
|
||||
R.string.battery_details_title, null,
|
||||
new UserHandle(UserHandle.getUserId(sipper.getUid())));
|
||||
new UserHandle(getUserIdToLaunchAdvancePowerUsageDetail(sipper)));
|
||||
}
|
||||
|
||||
private static @UserIdInt int getUserIdToLaunchAdvancePowerUsageDetail(BatterySipper bs) {
|
||||
if (bs.drainType == BatterySipper.DrainType.USER) {
|
||||
return ActivityManager.getCurrentUser();
|
||||
}
|
||||
return UserHandle.getUserId(bs.getUid());
|
||||
}
|
||||
|
||||
public static void startBatteryDetailPage(SettingsActivity caller, PreferenceFragment fragment,
|
||||
|
||||
@@ -428,7 +428,8 @@ public class PowerUsageSummary extends PowerUsageBase implements
|
||||
}
|
||||
|
||||
private static boolean isSystemUid(int uid) {
|
||||
return uid >= Process.SYSTEM_UID && uid < Process.FIRST_APPLICATION_UID;
|
||||
final int appUid = UserHandle.getAppId(uid);
|
||||
return appUid >= Process.SYSTEM_UID && appUid < Process.FIRST_APPLICATION_UID;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -34,10 +34,6 @@ public class SavedQueryController implements LoaderManager.LoaderCallbacks,
|
||||
MenuItem.OnMenuItemClickListener {
|
||||
|
||||
// TODO: make a generic background task manager to handle one-off tasks like this one.
|
||||
|
||||
private static final int LOADER_ID_SAVE_QUERY_TASK = 0;
|
||||
private static final int LOADER_ID_REMOVE_QUERY_TASK = 1;
|
||||
private static final int LOADER_ID_SAVED_QUERIES = 2;
|
||||
private static final String ARG_QUERY = "remove_query";
|
||||
private static final String TAG = "SearchSavedQueryCtrl";
|
||||
|
||||
@@ -60,11 +56,11 @@ public class SavedQueryController implements LoaderManager.LoaderCallbacks,
|
||||
@Override
|
||||
public Loader onCreateLoader(int id, Bundle args) {
|
||||
switch (id) {
|
||||
case LOADER_ID_SAVE_QUERY_TASK:
|
||||
case SearchFragment.SearchLoaderId.SAVE_QUERY_TASK:
|
||||
return new SavedQueryRecorder(mContext, args.getString(ARG_QUERY));
|
||||
case LOADER_ID_REMOVE_QUERY_TASK:
|
||||
case SearchFragment.SearchLoaderId.REMOVE_QUERY_TASK:
|
||||
return new SavedQueryRemover(mContext);
|
||||
case LOADER_ID_SAVED_QUERIES:
|
||||
case SearchFragment.SearchLoaderId.SAVED_QUERIES:
|
||||
return mSearchFeatureProvider.getSavedQueryLoader(mContext);
|
||||
}
|
||||
return null;
|
||||
@@ -73,10 +69,11 @@ public class SavedQueryController implements LoaderManager.LoaderCallbacks,
|
||||
@Override
|
||||
public void onLoadFinished(Loader loader, Object data) {
|
||||
switch (loader.getId()) {
|
||||
case LOADER_ID_REMOVE_QUERY_TASK:
|
||||
mLoaderManager.restartLoader(LOADER_ID_SAVED_QUERIES, null, this);
|
||||
case SearchFragment.SearchLoaderId.REMOVE_QUERY_TASK:
|
||||
mLoaderManager.restartLoader(SearchFragment.SearchLoaderId.SAVED_QUERIES,
|
||||
null /* args */, this /* callback */);
|
||||
break;
|
||||
case LOADER_ID_SAVED_QUERIES:
|
||||
case SearchFragment.SearchLoaderId.SAVED_QUERIES:
|
||||
if (SettingsSearchIndexablesProvider.DEBUG) {
|
||||
Log.d(TAG, "Saved queries loaded");
|
||||
}
|
||||
@@ -107,7 +104,8 @@ public class SavedQueryController implements LoaderManager.LoaderCallbacks,
|
||||
public void saveQuery(String query) {
|
||||
final Bundle args = new Bundle();
|
||||
args.putString(ARG_QUERY, query);
|
||||
mLoaderManager.restartLoader(LOADER_ID_SAVE_QUERY_TASK, args, this);
|
||||
mLoaderManager.restartLoader(SearchFragment.SearchLoaderId.SAVE_QUERY_TASK, args,
|
||||
this /* callback */);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -115,13 +113,15 @@ public class SavedQueryController implements LoaderManager.LoaderCallbacks,
|
||||
*/
|
||||
public void removeQueries() {
|
||||
final Bundle args = new Bundle();
|
||||
mLoaderManager.restartLoader(LOADER_ID_REMOVE_QUERY_TASK, args, this);
|
||||
mLoaderManager.restartLoader(SearchFragment.SearchLoaderId.REMOVE_QUERY_TASK, args,
|
||||
this /* callback */);
|
||||
}
|
||||
|
||||
public void loadSavedQueries() {
|
||||
if (SettingsSearchIndexablesProvider.DEBUG) {
|
||||
Log.d(TAG, "loading saved queries");
|
||||
}
|
||||
mLoaderManager.restartLoader(LOADER_ID_SAVED_QUERIES, null, this);
|
||||
mLoaderManager.restartLoader(SearchFragment.SearchLoaderId.SAVED_QUERIES, null /* args */,
|
||||
this /* callback */);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,15 +77,19 @@ public class SearchFragment extends InstrumentedFragment implements SearchView.O
|
||||
private static final String STATE_NEVER_ENTERED_QUERY = "state_never_entered_query";
|
||||
private static final String STATE_RESULT_CLICK_COUNT = "state_result_click_count";
|
||||
|
||||
// Loader IDs
|
||||
@VisibleForTesting
|
||||
static final int LOADER_ID_DATABASE = 1;
|
||||
@VisibleForTesting
|
||||
static final int LOADER_ID_INSTALLED_APPS = 2;
|
||||
@VisibleForTesting
|
||||
static final int LOADER_ID_ACCESSIBILITY_SERVICES = 3;
|
||||
@VisibleForTesting
|
||||
static final int LOADER_ID_INPUT_DEVICES = 4;
|
||||
static final class SearchLoaderId {
|
||||
// Search Query IDs
|
||||
public static final int DATABASE = 1;
|
||||
public static final int INSTALLED_APPS = 2;
|
||||
public static final int ACCESSIBILITY_SERVICES = 3;
|
||||
public static final int INPUT_DEVICES = 4;
|
||||
|
||||
// Saved Query IDs
|
||||
public static final int SAVE_QUERY_TASK = 5;
|
||||
public static final int REMOVE_QUERY_TASK = 6;
|
||||
public static final int SAVED_QUERIES = 7;
|
||||
}
|
||||
|
||||
|
||||
private static final int NUM_QUERY_LOADERS = 4;
|
||||
|
||||
@@ -283,10 +287,10 @@ public class SearchFragment extends InstrumentedFragment implements SearchView.O
|
||||
|
||||
if (isEmptyQuery) {
|
||||
final LoaderManager loaderManager = getLoaderManager();
|
||||
loaderManager.destroyLoader(LOADER_ID_DATABASE);
|
||||
loaderManager.destroyLoader(LOADER_ID_INSTALLED_APPS);
|
||||
loaderManager.destroyLoader(LOADER_ID_ACCESSIBILITY_SERVICES);
|
||||
loaderManager.destroyLoader(LOADER_ID_INPUT_DEVICES);
|
||||
loaderManager.destroyLoader(SearchLoaderId.DATABASE);
|
||||
loaderManager.destroyLoader(SearchLoaderId.INSTALLED_APPS);
|
||||
loaderManager.destroyLoader(SearchLoaderId.ACCESSIBILITY_SERVICES);
|
||||
loaderManager.destroyLoader(SearchLoaderId.INPUT_DEVICES);
|
||||
mShowingSavedQuery = true;
|
||||
mSavedQueryController.loadSavedQueries();
|
||||
mSearchFeatureProvider.hideFeedbackButton();
|
||||
@@ -311,13 +315,13 @@ public class SearchFragment extends InstrumentedFragment implements SearchView.O
|
||||
final Activity activity = getActivity();
|
||||
|
||||
switch (id) {
|
||||
case LOADER_ID_DATABASE:
|
||||
case SearchLoaderId.DATABASE:
|
||||
return mSearchFeatureProvider.getDatabaseSearchLoader(activity, mQuery);
|
||||
case LOADER_ID_INSTALLED_APPS:
|
||||
case SearchLoaderId.INSTALLED_APPS:
|
||||
return mSearchFeatureProvider.getInstalledAppSearchLoader(activity, mQuery);
|
||||
case LOADER_ID_ACCESSIBILITY_SERVICES:
|
||||
case SearchLoaderId.ACCESSIBILITY_SERVICES:
|
||||
return mSearchFeatureProvider.getAccessibilityServiceResultLoader(activity, mQuery);
|
||||
case LOADER_ID_INPUT_DEVICES:
|
||||
case SearchLoaderId.INPUT_DEVICES:
|
||||
return mSearchFeatureProvider.getInputDeviceResultLoader(activity, mQuery);
|
||||
default:
|
||||
return null;
|
||||
@@ -351,13 +355,13 @@ public class SearchFragment extends InstrumentedFragment implements SearchView.O
|
||||
mSavedQueryController.loadSavedQueries();
|
||||
} else {
|
||||
final LoaderManager loaderManager = getLoaderManager();
|
||||
loaderManager.initLoader(LOADER_ID_DATABASE, null /* args */, this /* callback */);
|
||||
loaderManager.initLoader(SearchLoaderId.DATABASE, null /* args */, this /* callback */);
|
||||
loaderManager.initLoader(
|
||||
LOADER_ID_INSTALLED_APPS, null /* args */, this /* callback */);
|
||||
SearchLoaderId.INSTALLED_APPS, null /* args */, this /* callback */);
|
||||
loaderManager.initLoader(
|
||||
LOADER_ID_ACCESSIBILITY_SERVICES, null /* args */, this /* callback */);
|
||||
SearchLoaderId.ACCESSIBILITY_SERVICES, null /* args */, this /* callback */);
|
||||
loaderManager.initLoader(
|
||||
LOADER_ID_INPUT_DEVICES, null /* args */, this /* callback */);
|
||||
SearchLoaderId.INPUT_DEVICES, null /* args */, this /* callback */);
|
||||
}
|
||||
|
||||
requery();
|
||||
@@ -395,12 +399,14 @@ public class SearchFragment extends InstrumentedFragment implements SearchView.O
|
||||
mShowingSavedQuery = false;
|
||||
final LoaderManager loaderManager = getLoaderManager();
|
||||
mUnfinishedLoadersCount.set(NUM_QUERY_LOADERS);
|
||||
loaderManager.restartLoader(LOADER_ID_DATABASE, null /* args */, this /* callback */);
|
||||
loaderManager.restartLoader(LOADER_ID_INSTALLED_APPS, null /* args */, this /* callback */);
|
||||
loaderManager.restartLoader(LOADER_ID_ACCESSIBILITY_SERVICES, null /* args */,
|
||||
this /* callback */);
|
||||
loaderManager.restartLoader(LOADER_ID_INPUT_DEVICES, null /* args */,
|
||||
this /* callback */);
|
||||
loaderManager.restartLoader(
|
||||
SearchLoaderId.DATABASE, null /* args */, this /* callback */);
|
||||
loaderManager.restartLoader(
|
||||
SearchLoaderId.INSTALLED_APPS, null /* args */, this /* callback */);
|
||||
loaderManager.restartLoader(
|
||||
SearchLoaderId.ACCESSIBILITY_SERVICES, null /* args */, this /* callback */);
|
||||
loaderManager.restartLoader(
|
||||
SearchLoaderId.INPUT_DEVICES, null /* args */, this /* callback */);
|
||||
}
|
||||
|
||||
public String getQuery() {
|
||||
|
||||
@@ -51,7 +51,7 @@ public class ConfigureKeyGuardDialog extends InstrumentedDialogFragment
|
||||
return new AlertDialog.Builder(getActivity())
|
||||
.setTitle(android.R.string.dialog_alert_title)
|
||||
.setMessage(R.string.credentials_configure_lock_screen_hint)
|
||||
.setPositiveButton(android.R.string.ok, this)
|
||||
.setPositiveButton(R.string.credentials_configure_lock_screen_button, this)
|
||||
.setNegativeButton(android.R.string.cancel, this)
|
||||
.create();
|
||||
}
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
LOCAL_PATH:= $(call my-dir)
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
# We only want this apk build for tests.
|
||||
LOCAL_MODULE_TAGS := tests
|
||||
LOCAL_CERTIFICATE := platform
|
||||
|
||||
LOCAL_JAVA_LIBRARIES := android.test.runner bouncycastle
|
||||
|
||||
LOCAL_STATIC_JAVA_LIBRARIES := \
|
||||
android-support-test \
|
||||
mockito-target \
|
||||
espresso-core \
|
||||
espresso-contrib-nodep \
|
||||
espresso-intents-nodep \
|
||||
ub-uiautomator \
|
||||
truth-prebuilt \
|
||||
legacy-android-test
|
||||
|
||||
# Include all test java files.
|
||||
LOCAL_SRC_FILES := $(call all-java-files-under, src)
|
||||
|
||||
LOCAL_PACKAGE_NAME := SettingsTests
|
||||
|
||||
LOCAL_INSTRUMENTATION_FOR := Settings
|
||||
|
||||
include $(BUILD_PACKAGE)
|
||||
@@ -1,67 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2008 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.android.settings.tests">
|
||||
|
||||
<uses-permission android:name="android.permission.BLUETOOTH" />
|
||||
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
|
||||
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
|
||||
<uses-permission android:name="android.permission.INTERACT_ACROSS_USERS" />
|
||||
<uses-permission android:name="android.permission.UPDATE_APP_OPS_STATS" />
|
||||
|
||||
<application>
|
||||
<uses-library android:name="android.test.runner" />
|
||||
<activity android:name="BluetoothRequestPermissionTest"
|
||||
android:label="Bluetooth Perm Test" >
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity android:name="Operator" android:label="Operator Hook Test" >
|
||||
<intent-filter>
|
||||
<action android:name="com.android.settings.OPERATOR_APPLICATION_SETTING" />
|
||||
</intent-filter>
|
||||
<meta-data android:name="com.android.settings.title" android:resource="@string/operator_settings_title" />
|
||||
<meta-data android:name="com.android.settings.summary" android:resource="@string/operator_settings_summary" />
|
||||
<meta-data android:name="com.android.settings.icon" android:resource="@drawable/ic_settings_applications" />
|
||||
</activity>
|
||||
<activity android:name="Manufacturer" android:label="Manufacturer Hook Test" >
|
||||
<intent-filter>
|
||||
<action android:name="com.android.settings.MANUFACTURER_APPLICATION_SETTING" />
|
||||
</intent-filter>
|
||||
<meta-data android:name="com.android.settings.title" android:resource="@string/manufacturer_settings_title" />
|
||||
<meta-data android:name="com.android.settings.summary" android:resource="@string/manufacturer_settings_summary" />
|
||||
<meta-data android:name="com.android.settings.icon" android:resource="@drawable/ic_settings_applications" />
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
<instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
|
||||
android:targetPackage="com.android.settings"
|
||||
android:label="Settings Test Cases">
|
||||
</instrumentation>
|
||||
|
||||
<instrumentation android:name="SettingsLaunchPerformance"
|
||||
android:targetPackage="com.android.settings"
|
||||
android:label="Settings Launch Performance">
|
||||
</instrumentation>
|
||||
|
||||
</manifest>
|
||||
@@ -1,83 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2016 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.android.settings.notification;
|
||||
|
||||
import static android.support.test.espresso.Espresso.onView;
|
||||
import static android.support.test.espresso.assertion.ViewAssertions.matches;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.hasDescendant;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.withId;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.withText;
|
||||
import static org.hamcrest.Matchers.allOf;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
|
||||
import android.content.Context;
|
||||
import android.media.AudioManager;
|
||||
import android.support.test.espresso.contrib.RecyclerViewActions;
|
||||
import android.support.test.filters.SmallTest;
|
||||
import android.support.test.rule.ActivityTestRule;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Settings;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
@SmallTest
|
||||
public class SoundSettingsIntegrationTest {
|
||||
|
||||
private AudioManager mAudioManager;
|
||||
private final String TRUNCATED_SUMMARY = "Ring volume at";
|
||||
|
||||
@Rule
|
||||
public ActivityTestRule<Settings> mActivityRule =
|
||||
new ActivityTestRule<>(Settings.class, true);
|
||||
|
||||
@Test
|
||||
public void soundPreferenceShowsCorrectSummaryOnSilentMode() {
|
||||
mAudioManager = (AudioManager) mActivityRule.getActivity().getApplicationContext()
|
||||
.getSystemService(Context.AUDIO_SERVICE);
|
||||
mAudioManager.setRingerMode(AudioManager.RINGER_MODE_SILENT);
|
||||
onView(withId(R.id.dashboard_container))
|
||||
.perform(RecyclerViewActions.scrollTo(
|
||||
hasDescendant(withText(R.string.sound_settings))));
|
||||
onView(withText(R.string.sound_settings_summary_silent)).check(matches(isDisplayed()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void soundPreferenceShowsCorrectSummaryOnVibrateMode() {
|
||||
mAudioManager = (AudioManager) mActivityRule.getActivity().getApplicationContext()
|
||||
.getSystemService(Context.AUDIO_SERVICE);
|
||||
mAudioManager.setRingerMode(AudioManager.RINGER_MODE_VIBRATE);
|
||||
onView(withId(R.id.dashboard_container)).perform(RecyclerViewActions
|
||||
.scrollTo(hasDescendant(withText(R.string.sound_settings))));
|
||||
onView(withText(R.string.sound_settings_summary_vibrate)).check(matches(isDisplayed()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void soundPreferenceShowsCorrectSummaryOnMaxVolume() {
|
||||
mAudioManager = (AudioManager) mActivityRule.getActivity().getApplicationContext()
|
||||
.getSystemService(Context.AUDIO_SERVICE);
|
||||
mAudioManager.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
|
||||
mAudioManager.setStreamVolume(AudioManager.STREAM_RING,
|
||||
mAudioManager.getStreamMaxVolume(AudioManager.STREAM_RING), 0);
|
||||
onView(withId(R.id.dashboard_container))
|
||||
.perform(RecyclerViewActions.scrollTo(
|
||||
hasDescendant(withText(R.string.sound_settings))));
|
||||
onView(withText(containsString(TRUNCATED_SUMMARY))).check(matches(isDisplayed()));
|
||||
}
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2016 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.android.settings.tests;
|
||||
|
||||
import android.app.Instrumentation;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.provider.Settings;
|
||||
import android.support.test.InstrumentationRegistry;
|
||||
import android.support.test.filters.SmallTest;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import com.android.settings.R;
|
||||
|
||||
import static android.support.test.espresso.Espresso.onView;
|
||||
import static android.support.test.espresso.action.ViewActions.click;
|
||||
import static android.support.test.espresso.assertion.ViewAssertions.matches;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.*;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.Visibility.VISIBLE;
|
||||
import static org.hamcrest.core.AllOf.allOf;
|
||||
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
@SmallTest
|
||||
public class DashboardAdapterTest {
|
||||
@Before
|
||||
public void SetUp() {
|
||||
Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation();
|
||||
instrumentation.startActivitySync(new Intent(Settings
|
||||
.ACTION_SETTINGS));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTileConsistency_ToggleSuggestionsAndOpenBluetooth_shouldInBluetooth()
|
||||
throws Exception{
|
||||
final Context context = InstrumentationRegistry.getTargetContext();
|
||||
|
||||
onView(allOf(withText(context.getString(R.string.suggestions_title)),
|
||||
withEffectiveVisibility(VISIBLE))).perform(click());
|
||||
onView(allOf(withText(context.getString(R.string.bluetooth_settings)),
|
||||
withEffectiveVisibility(VISIBLE))).perform(click());
|
||||
|
||||
// It should go to Bluetooth sub page, not other page or crash
|
||||
onView(allOf(withText(context.getString(R.string.bluetooth_settings)),
|
||||
withEffectiveVisibility(VISIBLE))).check(matches(isDisplayed()));
|
||||
|
||||
}
|
||||
}
|
||||
@@ -53,6 +53,7 @@ import com.android.settings.TestConfig;
|
||||
import com.android.settings.applications.LayoutPreference;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.testutils.FakeFeatureFactory;
|
||||
import com.android.settings.testutils.shadow.ShadowActivityManager;
|
||||
import com.android.settings.testutils.shadow.ShadowEntityHeaderController;
|
||||
import com.android.settings.widget.EntityHeaderController;
|
||||
import com.android.settingslib.applications.AppUtils;
|
||||
@@ -78,7 +79,7 @@ import java.util.List;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION,
|
||||
shadows = ShadowEntityHeaderController.class)
|
||||
shadows = {ShadowEntityHeaderController.class, ShadowActivityManager.class})
|
||||
public class AdvancedPowerUsageDetailTest {
|
||||
private static final String APP_LABEL = "app label";
|
||||
private static final String SUMMARY = "summary";
|
||||
@@ -349,6 +350,22 @@ public class AdvancedPowerUsageDetailTest {
|
||||
nullable(CharSequence.class), eq(new UserHandle(10)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStartBatteryDetailPage_typeUser_startByCurrentUser() {
|
||||
mBatterySipper.drainType = BatterySipper.DrainType.USER;
|
||||
mBatterySipper.userId = 10;
|
||||
|
||||
final int currentUser = 20;
|
||||
ShadowActivityManager.setCurrentUser(currentUser);
|
||||
AdvancedPowerUsageDetail.startBatteryDetailPage(mTestActivity, mBatteryUtils, null,
|
||||
mBatteryStatsHelper, 0, mBatteryEntry, USAGE_PERCENT, null);
|
||||
|
||||
|
||||
verify(mTestActivity).startPreferencePanelAsUser(
|
||||
nullable(Fragment.class), nullable(String.class), nullable(Bundle.class), anyInt(),
|
||||
nullable(CharSequence.class), eq(new UserHandle(currentUser)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStartBatteryDetailPage_noBatteryUsage_hasBasicData() {
|
||||
final ArgumentCaptor<Bundle> captor = ArgumentCaptor.forClass(Bundle.class);
|
||||
|
||||
@@ -410,9 +410,9 @@ public class SearchFragmentTest {
|
||||
|
||||
fragment.onIndexingFinished();
|
||||
|
||||
verify(loaderManager).initLoader(eq(SearchFragment.LOADER_ID_DATABASE),
|
||||
verify(loaderManager).initLoader(eq(SearchFragment.SearchLoaderId.DATABASE),
|
||||
eq(null), any(LoaderManager.LoaderCallbacks.class));
|
||||
verify(loaderManager).initLoader(eq(SearchFragment.LOADER_ID_INSTALLED_APPS),
|
||||
verify(loaderManager).initLoader(eq(SearchFragment.SearchLoaderId.INSTALLED_APPS),
|
||||
eq(null), any(LoaderManager.LoaderCallbacks.class));
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* 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.testutils.shadow;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
|
||||
import org.robolectric.annotation.Implementation;
|
||||
import org.robolectric.annotation.Implements;
|
||||
|
||||
@Implements(ActivityManager.class)
|
||||
public class ShadowActivityManager {
|
||||
private static int sCurrentUserId = 0;
|
||||
|
||||
@Implementation
|
||||
public static int getCurrentUser() {
|
||||
return sCurrentUserId;
|
||||
}
|
||||
|
||||
public static void setCurrentUser(int userId) {
|
||||
sCurrentUserId = userId;
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,7 @@ LOCAL_STATIC_JAVA_LIBRARIES := \
|
||||
mockito-target-minus-junit4 \
|
||||
truth-prebuilt \
|
||||
ub-uiautomator \
|
||||
espresso-contrib-nodep \
|
||||
espresso-intents-nodep \
|
||||
|
||||
|
||||
|
||||
@@ -17,8 +17,41 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.android.settings.tests.unit">
|
||||
|
||||
<uses-permission android:name="android.permission.BLUETOOTH" />
|
||||
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
|
||||
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
|
||||
<uses-permission android:name="android.permission.INTERACT_ACROSS_USERS" />
|
||||
<uses-permission android:name="android.permission.UPDATE_APP_OPS_STATS" />
|
||||
|
||||
<application>
|
||||
<uses-library android:name="android.test.runner" />
|
||||
<activity android:name="com.android.settings.tests.BluetoothRequestPermissionTest"
|
||||
android:label="Bluetooth Perm Test" >
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity android:name="Operator" android:label="Operator Hook Test" >
|
||||
<intent-filter>
|
||||
<action android:name="com.android.settings.OPERATOR_APPLICATION_SETTING" />
|
||||
</intent-filter>
|
||||
<meta-data android:name="com.android.settings.title" android:resource="@string/operator_settings_title" />
|
||||
<meta-data android:name="com.android.settings.summary" android:resource="@string/operator_settings_summary" />
|
||||
<meta-data android:name="com.android.settings.icon" android:resource="@drawable/ic_settings_applications" />
|
||||
</activity>
|
||||
<activity android:name="Manufacturer" android:label="Manufacturer Hook Test" >
|
||||
<intent-filter>
|
||||
<action android:name="com.android.settings.MANUFACTURER_APPLICATION_SETTING" />
|
||||
</intent-filter>
|
||||
<meta-data android:name="com.android.settings.title" android:resource="@string/manufacturer_settings_title" />
|
||||
<meta-data android:name="com.android.settings.summary" android:resource="@string/manufacturer_settings_summary" />
|
||||
<meta-data android:name="com.android.settings.icon" android:resource="@drawable/ic_settings_applications" />
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
<instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
|
||||
@@ -26,4 +59,9 @@
|
||||
android:label="Settings Test Cases">
|
||||
</instrumentation>
|
||||
|
||||
<instrumentation android:name="com.android.settings.tests.SettingsLaunchPerformance"
|
||||
android:targetPackage="com.android.settings"
|
||||
android:label="Settings Launch Performance">
|
||||
</instrumentation>
|
||||
|
||||
</manifest>
|
||||
|
||||
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user