diff --git a/res/xml/top_level_settings.xml b/res/xml/top_level_settings.xml index 7aed02158cc..171fe7867d6 100644 --- a/res/xml/top_level_settings.xml +++ b/res/xml/top_level_settings.xml @@ -34,12 +34,13 @@ android:title="@string/connected_devices_dashboard_title" android:summary="@string/summary_placeholder" android:icon="@drawable/ic_homepage_connected_device" - android:fragment="com.android.settings.connecteddevice.ConnectedDeviceDashboardFragment"/> + android:fragment="com.android.settings.connecteddevice.ConnectedDeviceDashboardFragment" + settings:controller="com.android.settings.connecteddevice.TopLevelConnectedDevicesPreferenceController"/> @@ -48,19 +49,20 @@ android:title="@string/power_usage_summary_title" android:summary="@string/summary_placeholder" android:icon="@drawable/ic_homepage_battery" - android:fragment="com.android.settings.fuelgauge.PowerUsageSummary"/> + android:fragment="com.android.settings.fuelgauge.PowerUsageSummary" + settings:controller="com.android.settings.fuelgauge.TopLevelBatteryPreferenceController"/> @@ -69,33 +71,36 @@ android:title="@string/storage_settings" android:summary="@string/summary_placeholder" android:icon="@drawable/ic_homepage_storage" - android:fragment="com.android.settings.deviceinfo.StorageSettings"/> + android:fragment="com.android.settings.deviceinfo.StorageSettings" + settings:controller="com.android.settings.deviceinfo.TopLevelStoragePreferenceController"/> + android:fragment="com.android.settings.security.SecuritySettings" + settings:controller="com.android.settings.security.TopLevelSecurityEntryPreferenceController"/> + android:fragment="com.android.settings.accounts.AccountDashboardFragment" + settings:controller="com.android.settings.accounts.TopLevelAccountEntryPreferenceController"/> diff --git a/src/com/android/settings/Settings.java b/src/com/android/settings/Settings.java index 4f011c19707..94de8da6e38 100644 --- a/src/com/android/settings/Settings.java +++ b/src/com/android/settings/Settings.java @@ -121,7 +121,6 @@ public class Settings extends SettingsActivity { } public static class DirectoryAccessSettingsActivity extends SettingsActivity { /* empty */ } - public static class TopLevelSettings extends SettingsActivity { /* empty */ } public static class ApnSettingsActivity extends SettingsActivity { /* empty */ } public static class WifiCallingSettingsActivity extends SettingsActivity { /* empty */ } public static class MemorySettingsActivity extends SettingsActivity { /* empty */ } diff --git a/src/com/android/settings/accounts/TopLevelAccountEntryPreferenceController.java b/src/com/android/settings/accounts/TopLevelAccountEntryPreferenceController.java new file mode 100644 index 00000000000..a8d93d589d8 --- /dev/null +++ b/src/com/android/settings/accounts/TopLevelAccountEntryPreferenceController.java @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2018 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.accounts; + +import android.content.Context; +import android.icu.text.ListFormatter; +import android.os.UserHandle; +import android.text.BidiFormatter; +import android.text.TextUtils; + +import com.android.settings.R; +import com.android.settings.core.BasePreferenceController; +import com.android.settingslib.accounts.AuthenticatorHelper; + +import java.util.ArrayList; +import java.util.List; + +public class TopLevelAccountEntryPreferenceController extends BasePreferenceController { + public TopLevelAccountEntryPreferenceController(Context context, String preferenceKey) { + super(context, preferenceKey); + } + + @Override + public int getAvailabilityStatus() { + return AVAILABLE_UNSEARCHABLE; + } + + @Override + public CharSequence getSummary() { + final AuthenticatorHelper authHelper = new AuthenticatorHelper(mContext, + UserHandle.of(UserHandle.myUserId()), null /* OnAccountsUpdateListener */); + final String[] types = authHelper.getEnabledAccountTypes(); + final BidiFormatter bidiFormatter = BidiFormatter.getInstance(); + final List summaries = new ArrayList<>(); + + if (types == null || types.length == 0) { + summaries.add(mContext.getString(R.string.account_dashboard_default_summary)); + } else { + // Show up to 3 account types, ignore any null value + int accountToAdd = Math.min(3, types.length); + + for (int i = 0; i < types.length && accountToAdd > 0; i++) { + final CharSequence label = authHelper.getLabelForType(mContext, types[i]); + if (TextUtils.isEmpty(label)) { + continue; + } + + summaries.add(bidiFormatter.unicodeWrap(label)); + accountToAdd--; + } + } + return ListFormatter.getInstance().format(summaries); + } +} diff --git a/src/com/android/settings/connecteddevice/TopLevelConnectedDevicesPreferenceController.java b/src/com/android/settings/connecteddevice/TopLevelConnectedDevicesPreferenceController.java new file mode 100644 index 00000000000..6f16db6e368 --- /dev/null +++ b/src/com/android/settings/connecteddevice/TopLevelConnectedDevicesPreferenceController.java @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2018 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 android.content.Context; + +import com.android.settings.core.BasePreferenceController; + +public class TopLevelConnectedDevicesPreferenceController extends BasePreferenceController { + + public TopLevelConnectedDevicesPreferenceController(Context context, + String preferenceKey) { + super(context, preferenceKey); + } + + @Override + public int getAvailabilityStatus() { + return AVAILABLE_UNSEARCHABLE; + } + + @Override + public CharSequence getSummary() { + return mContext.getText( + AdvancedConnectedDeviceController.getConnectedDevicesSummaryResourceId(mContext)); + } +} diff --git a/src/com/android/settings/dashboard/DashboardSummary.java b/src/com/android/settings/dashboard/DashboardSummary.java index c6b69e9953d..ec5f7dd4715 100644 --- a/src/com/android/settings/dashboard/DashboardSummary.java +++ b/src/com/android/settings/dashboard/DashboardSummary.java @@ -26,6 +26,11 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import androidx.annotation.VisibleForTesting; +import androidx.annotation.WorkerThread; +import androidx.loader.app.LoaderManager; +import androidx.recyclerview.widget.LinearLayoutManager; + import com.android.internal.logging.nano.MetricsProto.MetricsEvent; import com.android.settings.R; import com.android.settings.core.InstrumentedFragment; @@ -46,11 +51,12 @@ import com.android.settingslib.utils.ThreadUtils; import java.util.List; -import androidx.annotation.VisibleForTesting; -import androidx.annotation.WorkerThread; -import androidx.loader.app.LoaderManager; -import androidx.recyclerview.widget.LinearLayoutManager; - +/** + * Deprecated in favor of {@link com.android.settings.homepage.TopLevelSettings} + * + * @deprecated + */ +@Deprecated public class DashboardSummary extends InstrumentedFragment implements CategoryListener, ConditionListener, FocusListener, SuggestionControllerMixinCompat.SuggestionControllerHost { diff --git a/src/com/android/settings/deviceinfo/TopLevelStoragePreferenceController.java b/src/com/android/settings/deviceinfo/TopLevelStoragePreferenceController.java new file mode 100644 index 00000000000..c6fc23b1df2 --- /dev/null +++ b/src/com/android/settings/deviceinfo/TopLevelStoragePreferenceController.java @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2018 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.deviceinfo; + +import android.content.Context; +import android.os.storage.StorageManager; +import android.text.format.Formatter; + +import com.android.settings.R; +import com.android.settings.core.BasePreferenceController; +import com.android.settingslib.deviceinfo.PrivateStorageInfo; +import com.android.settingslib.deviceinfo.StorageManagerVolumeProvider; + +import java.text.NumberFormat; + +public class TopLevelStoragePreferenceController extends BasePreferenceController { + + private final StorageManager mStorageManager; + private final StorageManagerVolumeProvider mStorageManagerVolumeProvider; + + public TopLevelStoragePreferenceController(Context context, String preferenceKey) { + super(context, preferenceKey); + mStorageManager = mContext.getSystemService(StorageManager.class); + mStorageManagerVolumeProvider = new StorageManagerVolumeProvider(mStorageManager); + } + + @Override + public int getAvailabilityStatus() { + return AVAILABLE_UNSEARCHABLE; + } + + @Override + public CharSequence getSummary() { + // TODO: Register listener. + final NumberFormat percentageFormat = NumberFormat.getPercentInstance(); + final PrivateStorageInfo info = PrivateStorageInfo.getPrivateStorageInfo( + mStorageManagerVolumeProvider); + double privateUsedBytes = info.totalBytes - info.freeBytes; + return mContext.getString(R.string.storage_summary, + percentageFormat.format(privateUsedBytes / info.totalBytes), + Formatter.formatFileSize(mContext, info.freeBytes)); + } +} diff --git a/src/com/android/settings/fuelgauge/PowerUsageSummary.java b/src/com/android/settings/fuelgauge/PowerUsageSummary.java index 2ae58763ba4..75631206e53 100644 --- a/src/com/android/settings/fuelgauge/PowerUsageSummary.java +++ b/src/com/android/settings/fuelgauge/PowerUsageSummary.java @@ -17,13 +17,13 @@ package com.android.settings.fuelgauge; import static com.android.settings.fuelgauge.BatteryBroadcastReceiver.BatteryUpdateType; +import static com.android.settings.fuelgauge.TopLevelBatteryPreferenceController.getDashboardLabel; import android.app.Activity; import android.content.Context; import android.os.BatteryStats; import android.os.Bundle; import android.provider.SearchIndexableResource; -import android.text.BidiFormatter; import android.text.format.Formatter; import android.view.Menu; import android.view.MenuInflater; @@ -32,6 +32,11 @@ import android.view.View; import android.view.View.OnLongClickListener; import android.widget.TextView; +import androidx.annotation.VisibleForTesting; +import androidx.loader.app.LoaderManager; +import androidx.loader.app.LoaderManager.LoaderCallbacks; +import androidx.loader.content.Loader; + import com.android.internal.logging.nano.MetricsProto.MetricsEvent; import com.android.settings.R; import com.android.settings.SettingsActivity; @@ -51,11 +56,6 @@ import com.android.settingslib.utils.StringUtil; import java.util.Collections; import java.util.List; -import androidx.annotation.VisibleForTesting; -import androidx.loader.app.LoaderManager; -import androidx.loader.app.LoaderManager.LoaderCallbacks; -import androidx.loader.content.Loader; - /** * Displays a list of apps and subsystems that consume power, ordered by how much power was * consumed since the last time it was unplugged. @@ -147,9 +147,9 @@ public class PowerUsageSummary extends PowerUsageBase implements OnLongClickList protected void updateViews(List batteryInfos) { final BatteryMeterView batteryView = mBatteryLayoutPref - .findViewById(R.id.battery_header_icon); + .findViewById(R.id.battery_header_icon); final TextView percentRemaining = - mBatteryLayoutPref.findViewById(R.id.battery_percent); + mBatteryLayoutPref.findViewById(R.id.battery_percent); final TextView summary1 = mBatteryLayoutPref.findViewById(R.id.summary1); final TextView summary2 = mBatteryLayoutPref.findViewById(R.id.summary2); BatteryInfo oldInfo = batteryInfos.get(0); @@ -160,13 +160,13 @@ public class PowerUsageSummary extends PowerUsageBase implements OnLongClickList // can sometimes say 0 time remaining because battery stats requires the phone // be unplugged for a period of time before being willing ot make an estimate. summary1.setText(mPowerFeatureProvider.getOldEstimateDebugString( - Formatter.formatShortElapsedTime(getContext(), - PowerUtil.convertUsToMs(oldInfo.remainingTimeUs)))); + Formatter.formatShortElapsedTime(getContext(), + PowerUtil.convertUsToMs(oldInfo.remainingTimeUs)))); // for this one we can just set the string directly summary2.setText(mPowerFeatureProvider.getEnhancedEstimateDebugString( - Formatter.formatShortElapsedTime(getContext(), - PowerUtil.convertUsToMs(newInfo.remainingTimeUs)))); + Formatter.formatShortElapsedTime(getContext(), + PowerUtil.convertUsToMs(newInfo.remainingTimeUs)))); batteryView.setBatteryLevel(oldInfo.batteryLevel); batteryView.setCharging(!oldInfo.discharging); @@ -419,19 +419,6 @@ public class PowerUsageSummary extends PowerUsageBase implements OnLongClickList } } - @VisibleForTesting - static CharSequence getDashboardLabel(Context context, BatteryInfo info) { - CharSequence label; - final BidiFormatter formatter = BidiFormatter.getInstance(); - if (info.remainingLabel == null) { - label = info.batteryPercentString; - } else { - label = context.getString(R.string.power_remaining_settings_home_page, - formatter.unicodeWrap(info.batteryPercentString), - formatter.unicodeWrap(info.remainingLabel)); - } - return label; - } public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER = new BaseSearchIndexProvider() { diff --git a/src/com/android/settings/fuelgauge/TopLevelBatteryPreferenceController.java b/src/com/android/settings/fuelgauge/TopLevelBatteryPreferenceController.java new file mode 100644 index 00000000000..82058183e53 --- /dev/null +++ b/src/com/android/settings/fuelgauge/TopLevelBatteryPreferenceController.java @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2018 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.fuelgauge; + +import android.content.Context; +import android.text.BidiFormatter; + +import androidx.preference.Preference; +import androidx.preference.PreferenceScreen; + +import com.android.settings.R; +import com.android.settings.core.BasePreferenceController; +import com.android.settingslib.core.lifecycle.LifecycleObserver; +import com.android.settingslib.core.lifecycle.events.OnStart; +import com.android.settingslib.core.lifecycle.events.OnStop; + +public class TopLevelBatteryPreferenceController extends BasePreferenceController implements + LifecycleObserver, OnStart, OnStop { + + private final BatteryBroadcastReceiver mBatteryBroadcastReceiver; + private Preference mPreference; + private BatteryInfo mBatteryInfo; + + public TopLevelBatteryPreferenceController(Context context, String preferenceKey) { + super(context, preferenceKey); + mBatteryBroadcastReceiver = new BatteryBroadcastReceiver(mContext); + mBatteryBroadcastReceiver.setBatteryChangedListener(type -> { + BatteryInfo.getBatteryInfo(mContext, info -> { + mBatteryInfo = info; + updateState(mPreference); + }, true /* shortString */); + }); + } + + @Override + public int getAvailabilityStatus() { + return AVAILABLE_UNSEARCHABLE; + } + + @Override + public void displayPreference(PreferenceScreen screen) { + super.displayPreference(screen); + mPreference = screen.findPreference(getPreferenceKey()); + } + + @Override + public void onStart() { + mBatteryBroadcastReceiver.register(); + } + + @Override + public void onStop() { + mBatteryBroadcastReceiver.unRegister(); + } + + @Override + public CharSequence getSummary() { + return getDashboardLabel(mContext, mBatteryInfo); + } + + static CharSequence getDashboardLabel(Context context, BatteryInfo info) { + if (info == null || context == null) { + return null; + } + CharSequence label; + final BidiFormatter formatter = BidiFormatter.getInstance(); + if (info.remainingLabel == null) { + label = info.batteryPercentString; + } else { + label = context.getString(R.string.power_remaining_settings_home_page, + formatter.unicodeWrap(info.batteryPercentString), + formatter.unicodeWrap(info.remainingLabel)); + } + return label; + } +} diff --git a/src/com/android/settings/security/TopLevelSecurityEntryPreferenceController.java b/src/com/android/settings/security/TopLevelSecurityEntryPreferenceController.java new file mode 100644 index 00000000000..4b004240685 --- /dev/null +++ b/src/com/android/settings/security/TopLevelSecurityEntryPreferenceController.java @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2018 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.security; + +import android.content.Context; +import android.hardware.face.FaceManager; +import android.hardware.fingerprint.FingerprintManager; + +import com.android.settings.R; +import com.android.settings.Utils; +import com.android.settings.core.BasePreferenceController; + +public class TopLevelSecurityEntryPreferenceController extends BasePreferenceController { + + public TopLevelSecurityEntryPreferenceController(Context context, String preferenceKey) { + super(context, preferenceKey); + } + + @Override + public int getAvailabilityStatus() { + return AVAILABLE_UNSEARCHABLE; + } + + @Override + public CharSequence getSummary() { + final FingerprintManager fpm = + Utils.getFingerprintManagerOrNull(mContext); + final FaceManager faceManager = + Utils.getFaceManagerOrNull(mContext); + if (faceManager != null && faceManager.isHardwareDetected()) { + return mContext.getText(R.string.security_dashboard_summary_face); + } else if (fpm != null && fpm.isHardwareDetected()) { + return mContext.getText(R.string.security_dashboard_summary); + } else { + return mContext.getText(R.string.security_dashboard_summary_no_fingerprint); + } + } +} diff --git a/tests/robotests/src/com/android/settings/accounts/AccountDashboardFragmentTest.java b/tests/robotests/src/com/android/settings/accounts/AccountDashboardFragmentTest.java index 40dcf7ad693..41ac4500b73 100644 --- a/tests/robotests/src/com/android/settings/accounts/AccountDashboardFragmentTest.java +++ b/tests/robotests/src/com/android/settings/accounts/AccountDashboardFragmentTest.java @@ -15,40 +15,20 @@ */ package com.android.settings.accounts; -import static com.android.settings.accounts.AccountDashboardFragmentTest - .ShadowAuthenticationHelper.LABELS; -import static com.android.settings.accounts.AccountDashboardFragmentTest - .ShadowAuthenticationHelper.TYPES; import static com.google.common.truth.Truth.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import android.content.Context; -import android.os.UserHandle; import android.provider.SearchIndexableResource; -import android.text.TextUtils; -import com.android.settings.R; -import com.android.settings.dashboard.SummaryLoader; -import com.android.settings.testutils.Robolectric; import com.android.settings.testutils.SettingsRobolectricTestRunner; -import com.android.settingslib.accounts.AuthenticatorHelper; import com.android.settingslib.drawer.CategoryKey; -import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.robolectric.RuntimeEnvironment; -import org.robolectric.annotation.Config; -import org.robolectric.annotation.Implementation; -import org.robolectric.annotation.Implements; -import org.robolectric.annotation.Resetter; import java.util.List; -import androidx.fragment.app.FragmentActivity; - @RunWith(SettingsRobolectricTestRunner.class) public class AccountDashboardFragmentTest { @@ -59,66 +39,11 @@ public class AccountDashboardFragmentTest { mFragment = new AccountDashboardFragment(); } - @After - public void tearDown() { - ShadowAuthenticationHelper.reset(); - } - @Test public void testCategory_isAccount() { assertThat(mFragment.getCategoryKey()).isEqualTo(CategoryKey.CATEGORY_ACCOUNT); } - @Test - @Config(shadows = { - ShadowAuthenticationHelper.class - }) - public void updateSummary_hasAccount_shouldDisplayUpTo3AccountTypes() { - final SummaryLoader loader = mock(SummaryLoader.class); - final FragmentActivity activity = Robolectric.buildActivity( - FragmentActivity.class).setup().get(); - - final SummaryLoader.SummaryProvider provider = - AccountDashboardFragment.SUMMARY_PROVIDER_FACTORY.createSummaryProvider(activity, - loader); - provider.setListening(true); - - verify(loader).setSummary(provider, LABELS[0] + ", " + LABELS[1] + ", and " + LABELS[2]); - } - - @Test - @Config(shadows = ShadowAuthenticationHelper.class) - public void updateSummary_noAccount_shouldDisplayDefaultSummary() { - ShadowAuthenticationHelper.setEnabledAccount(null); - final SummaryLoader loader = mock(SummaryLoader.class); - final FragmentActivity activity = Robolectric.buildActivity(FragmentActivity.class).setup().get(); - - final SummaryLoader.SummaryProvider provider = - AccountDashboardFragment.SUMMARY_PROVIDER_FACTORY.createSummaryProvider(activity, - loader); - provider.setListening(true); - - verify(loader).setSummary(provider, - activity.getString(R.string.account_dashboard_default_summary)); - } - - @Test - @Config(shadows = ShadowAuthenticationHelper.class) - public void updateSummary_noAccountTypeLabel_shouldNotDisplayNullEntry() { - final SummaryLoader loader = mock(SummaryLoader.class); - final FragmentActivity activity = Robolectric.buildActivity(FragmentActivity.class).setup().get(); - final String[] enabledAccounts = {TYPES[0], "unlabeled_account_type", TYPES[1]}; - ShadowAuthenticationHelper.setEnabledAccount(enabledAccounts); - - final SummaryLoader.SummaryProvider provider = - AccountDashboardFragment.SUMMARY_PROVIDER_FACTORY.createSummaryProvider(activity, - loader); - provider.setListening(true); - - // should only show the 2 accounts with labels - verify(loader).setSummary(provider, LABELS[0] + " and " + LABELS[1]); - } - @Test public void testSearchIndexProvider_shouldIndexResource() { final List indexRes = @@ -129,43 +54,5 @@ public class AccountDashboardFragmentTest { assertThat(indexRes.get(0).xmlResId).isEqualTo(mFragment.getPreferenceScreenResId()); } - @Implements(AuthenticatorHelper.class) - public static class ShadowAuthenticationHelper { - static final String[] TYPES = {"type1", "type2", "type3", "type4"}; - static final String[] LABELS = {"LABEL1", "LABEL2", "LABEL3", "LABEL4"}; - private static String[] sEnabledAccount = TYPES; - - public void __constructor__(Context context, UserHandle userHandle, - AuthenticatorHelper.OnAccountsUpdateListener listener) { - } - - private static void setEnabledAccount(String[] enabledAccount) { - sEnabledAccount = enabledAccount; - } - - @Resetter - public static void reset() { - sEnabledAccount = TYPES; - } - - @Implementation - public String[] getEnabledAccountTypes() { - return sEnabledAccount; - } - - @Implementation - public CharSequence getLabelForType(Context context, final String accountType) { - if (TextUtils.equals(accountType, TYPES[0])) { - return LABELS[0]; - } else if (TextUtils.equals(accountType, TYPES[1])) { - return LABELS[1]; - } else if (TextUtils.equals(accountType, TYPES[2])) { - return LABELS[2]; - } else if (TextUtils.equals(accountType, TYPES[3])) { - return LABELS[3]; - } - return null; - } - } } diff --git a/tests/robotests/src/com/android/settings/accounts/TopLevelAccountEntryPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accounts/TopLevelAccountEntryPreferenceControllerTest.java new file mode 100644 index 00000000000..79e292dcf94 --- /dev/null +++ b/tests/robotests/src/com/android/settings/accounts/TopLevelAccountEntryPreferenceControllerTest.java @@ -0,0 +1,126 @@ +/* + * Copyright (C) 2018 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.accounts; + +import static com.android.settings.accounts.TopLevelAccountEntryPreferenceControllerTest + .ShadowAuthenticationHelper.LABELS; +import static com.android.settings.accounts.TopLevelAccountEntryPreferenceControllerTest + .ShadowAuthenticationHelper.TYPES; + +import static com.google.common.truth.Truth.assertThat; + +import android.content.Context; +import android.os.UserHandle; +import android.text.TextUtils; + +import com.android.settings.R; +import com.android.settings.testutils.SettingsRobolectricTestRunner; +import com.android.settingslib.accounts.AuthenticatorHelper; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.robolectric.RuntimeEnvironment; +import org.robolectric.annotation.Config; +import org.robolectric.annotation.Implementation; +import org.robolectric.annotation.Implements; +import org.robolectric.annotation.Resetter; + +@RunWith(SettingsRobolectricTestRunner.class) +@Config(shadows = {TopLevelAccountEntryPreferenceControllerTest.ShadowAuthenticationHelper.class}) +public class TopLevelAccountEntryPreferenceControllerTest { + + private TopLevelAccountEntryPreferenceController mController; + private Context mContext; + + @Before + public void setUp() { + mContext = RuntimeEnvironment.application; + mController = new TopLevelAccountEntryPreferenceController(mContext, "test_key"); + } + + @After + public void tearDown() { + ShadowAuthenticationHelper.reset(); + } + + @Test + + public void updateSummary_hasAccount_shouldDisplayUpTo3AccountTypes() { + assertThat(mController.getSummary()) + .isEqualTo(LABELS[0] + ", " + LABELS[1] + ", and " + LABELS[2]); + } + + @Test + public void updateSummary_noAccount_shouldDisplayDefaultSummary() { + ShadowAuthenticationHelper.setEnabledAccount(null); + + assertThat(mController.getSummary()).isEqualTo( + mContext.getText(R.string.account_dashboard_default_summary)); + } + + @Test + public void updateSummary_noAccountTypeLabel_shouldNotDisplayNullEntry() { + final String[] enabledAccounts = {TYPES[0], "unlabeled_account_type", TYPES[1]}; + ShadowAuthenticationHelper.setEnabledAccount(enabledAccounts); + + + // should only show the 2 accounts with labels + assertThat(mController.getSummary()).isEqualTo(LABELS[0] + " and " + LABELS[1]); + } + + @Implements(AuthenticatorHelper.class) + public static class ShadowAuthenticationHelper { + + static final String[] TYPES = {"type1", "type2", "type3", "type4"}; + static final String[] LABELS = {"LABEL1", "LABEL2", "LABEL3", "LABEL4"}; + private static String[] sEnabledAccount = TYPES; + + public void __constructor__(Context context, UserHandle userHandle, + AuthenticatorHelper.OnAccountsUpdateListener listener) { + } + + private static void setEnabledAccount(String[] enabledAccount) { + sEnabledAccount = enabledAccount; + } + + @Resetter + public static void reset() { + sEnabledAccount = TYPES; + } + + @Implementation + public String[] getEnabledAccountTypes() { + return sEnabledAccount; + } + + @Implementation + public CharSequence getLabelForType(Context context, final String accountType) { + if (TextUtils.equals(accountType, TYPES[0])) { + return LABELS[0]; + } else if (TextUtils.equals(accountType, TYPES[1])) { + return LABELS[1]; + } else if (TextUtils.equals(accountType, TYPES[2])) { + return LABELS[2]; + } else if (TextUtils.equals(accountType, TYPES[3])) { + return LABELS[3]; + } + return null; + } + } +} diff --git a/tests/robotests/src/com/android/settings/connecteddevice/TopLevelConnectedDevicesPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/connecteddevice/TopLevelConnectedDevicesPreferenceControllerTest.java new file mode 100644 index 00000000000..8816bec88f3 --- /dev/null +++ b/tests/robotests/src/com/android/settings/connecteddevice/TopLevelConnectedDevicesPreferenceControllerTest.java @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2018 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.content.Context; + +import com.android.settings.R; +import com.android.settings.testutils.SettingsRobolectricTestRunner; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.robolectric.RuntimeEnvironment; +import org.robolectric.annotation.Config; +import org.robolectric.annotation.Implementation; +import org.robolectric.annotation.Implements; + +@RunWith(SettingsRobolectricTestRunner.class) +public class TopLevelConnectedDevicesPreferenceControllerTest { + + private Context mContext; + private TopLevelConnectedDevicesPreferenceController mController; + + @Before + public void setUp() { + mContext = RuntimeEnvironment.application; + mController = new TopLevelConnectedDevicesPreferenceController(mContext, "test_key"); + } + + @Test + @Config(shadows = ShadowAdvancedConnectedDeviceController.class) + public void getSummary_shouldCallAdvancedConnectedDeviceController() { + assertThat(mController.getSummary()) + .isEqualTo(mContext.getText(R.string.settings_label_launcher)); + } + + @Implements(AdvancedConnectedDeviceController.class) + private static class ShadowAdvancedConnectedDeviceController { + + @Implementation + public static int getConnectedDevicesSummaryResourceId(Context context) { + return R.string.settings_label_launcher; + } + } +} diff --git a/tests/robotests/src/com/android/settings/deviceinfo/StorageSettingsTest.java b/tests/robotests/src/com/android/settings/deviceinfo/StorageSettingsTest.java index 943bd9d2630..cb02c76846f 100644 --- a/tests/robotests/src/com/android/settings/deviceinfo/StorageSettingsTest.java +++ b/tests/robotests/src/com/android/settings/deviceinfo/StorageSettingsTest.java @@ -17,7 +17,6 @@ package com.android.settings.deviceinfo; import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.nullable; import static org.mockito.Mockito.RETURNS_DEEP_STUBS; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; @@ -25,14 +24,9 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import android.app.Activity; -import android.app.usage.StorageStatsManager; import android.content.Intent; -import android.icu.text.NumberFormat; import android.os.storage.VolumeInfo; -import android.text.format.Formatter; -import com.android.settings.R; -import com.android.settings.dashboard.SummaryLoader; import com.android.settings.testutils.SettingsRobolectricTestRunner; import com.android.settingslib.deviceinfo.StorageManagerVolumeProvider; @@ -41,8 +35,6 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import org.robolectric.RuntimeEnvironment; -import org.robolectric.util.ReflectionHelpers; import java.util.ArrayList; import java.util.List; @@ -65,34 +57,6 @@ public class StorageSettingsTest { when(mStorageManagerVolumeProvider.getVolumes()).thenReturn(mVolumes); } - @Test - public void updateSummary_shouldDisplayUsedPercentAndFreeSpace() throws Exception { - final SummaryLoader loader = mock(SummaryLoader.class); - final SummaryLoader.SummaryProvider provider = - StorageSettings.SUMMARY_PROVIDER_FACTORY.createSummaryProvider(mActivity, loader); - final VolumeInfo volumeInfo = mVolumes.get(0); - when(volumeInfo.isMountedReadable()).thenReturn(true); - when(volumeInfo.getType()).thenReturn(VolumeInfo.TYPE_PRIVATE); - when(mStorageManagerVolumeProvider - .getTotalBytes(nullable(StorageStatsManager.class), nullable(VolumeInfo.class))) - .thenReturn(500L); - when(mStorageManagerVolumeProvider - .getFreeBytes(nullable(StorageStatsManager.class), nullable(VolumeInfo.class))) - .thenReturn(0L); - - ReflectionHelpers - .setField(provider, "mStorageManagerVolumeProvider", mStorageManagerVolumeProvider); - ReflectionHelpers.setField(provider, "mContext", RuntimeEnvironment.application); - - provider.setListening(true); - - final String percentage = NumberFormat.getPercentInstance().format(1); - final String freeSpace = Formatter.formatFileSize(RuntimeEnvironment.application, 0); - verify(loader).setSummary(provider, - RuntimeEnvironment.application.getString( - R.string.storage_summary, percentage, freeSpace)); - } - @Test public void handlePublicVolumeClick_startsANonNullActivityWhenVolumeHasNoBrowse() { VolumeInfo volumeInfo = mock(VolumeInfo.class, RETURNS_DEEP_STUBS); diff --git a/tests/robotests/src/com/android/settings/deviceinfo/TopLevelStoragePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/TopLevelStoragePreferenceControllerTest.java new file mode 100644 index 00000000000..00484df3efc --- /dev/null +++ b/tests/robotests/src/com/android/settings/deviceinfo/TopLevelStoragePreferenceControllerTest.java @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2018 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.deviceinfo; + +import static com.google.common.truth.Truth.assertThat; + +import static org.mockito.ArgumentMatchers.nullable; +import static org.mockito.Mockito.RETURNS_DEEP_STUBS; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import android.app.usage.StorageStatsManager; +import android.content.Context; +import android.icu.text.NumberFormat; +import android.os.storage.VolumeInfo; +import android.text.format.Formatter; + +import com.android.settings.R; +import com.android.settings.testutils.SettingsRobolectricTestRunner; +import com.android.settingslib.deviceinfo.StorageManagerVolumeProvider; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.robolectric.RuntimeEnvironment; +import org.robolectric.util.ReflectionHelpers; + +import java.util.ArrayList; +import java.util.List; + +@RunWith(SettingsRobolectricTestRunner.class) +public class TopLevelStoragePreferenceControllerTest { + + @Mock + private StorageManagerVolumeProvider mStorageManagerVolumeProvider; + + private Context mContext; + private TopLevelStoragePreferenceController mController; + private List mVolumes; + + @Before + public void setUp() { + MockitoAnnotations.initMocks(this); + + mContext = RuntimeEnvironment.application; + mVolumes = new ArrayList<>(); + mVolumes.add(mock(VolumeInfo.class, RETURNS_DEEP_STUBS)); + when(mStorageManagerVolumeProvider.getVolumes()).thenReturn(mVolumes); + + mController = new TopLevelStoragePreferenceController(mContext, "test_key"); + } + + @Test + public void updateSummary_shouldDisplayUsedPercentAndFreeSpace() throws Exception { + final VolumeInfo volumeInfo = mVolumes.get(0); + when(volumeInfo.isMountedReadable()).thenReturn(true); + when(volumeInfo.getType()).thenReturn(VolumeInfo.TYPE_PRIVATE); + when(mStorageManagerVolumeProvider + .getTotalBytes(nullable(StorageStatsManager.class), nullable(VolumeInfo.class))) + .thenReturn(500L); + when(mStorageManagerVolumeProvider + .getFreeBytes(nullable(StorageStatsManager.class), nullable(VolumeInfo.class))) + .thenReturn(0L); + + ReflectionHelpers.setField(mController, + "mStorageManagerVolumeProvider", mStorageManagerVolumeProvider); + + final String percentage = NumberFormat.getPercentInstance().format(1); + final String freeSpace = Formatter.formatFileSize(RuntimeEnvironment.application, 0); + assertThat(mController.getSummary()).isEqualTo( + RuntimeEnvironment.application.getString( + R.string.storage_summary, percentage, freeSpace)); + } +} diff --git a/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageSummaryTest.java b/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageSummaryTest.java index 68d9994cf9c..cf1a5f346d7 100644 --- a/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageSummaryTest.java +++ b/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageSummaryTest.java @@ -16,7 +16,9 @@ package com.android.settings.fuelgauge; import static com.android.settings.fuelgauge.PowerUsageSummary.MENU_ADVANCED_BATTERY; + import static com.google.common.truth.Truth.assertThat; + import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyInt; import static org.mockito.Matchers.anyLong; @@ -40,6 +42,8 @@ import android.view.MenuItem; import android.view.View; import android.widget.TextView; +import androidx.loader.app.LoaderManager; + import com.android.internal.os.BatterySipper; import com.android.internal.os.BatteryStatsHelper; import com.android.settings.R; @@ -50,7 +54,6 @@ import com.android.settings.testutils.FakeFeatureFactory; import com.android.settings.testutils.SettingsRobolectricTestRunner; import com.android.settings.testutils.XmlTestUtils; import com.android.settings.testutils.shadow.SettingsShadowResources; -import com.android.settingslib.core.AbstractPreferenceController; import org.junit.Before; import org.junit.BeforeClass; @@ -69,8 +72,6 @@ import org.robolectric.annotation.Config; import java.util.ArrayList; import java.util.List; -import androidx.loader.app.LoaderManager; - // TODO: Improve this test class so that it starts up the real activity and fragment. @RunWith(SettingsRobolectricTestRunner.class) @Config(shadows = { @@ -343,18 +344,6 @@ public class PowerUsageSummaryTest { verify(mFragment).restartBatteryTipLoader(); } - @Test - public void getDashboardLabel_returnsCorrectLabel() { - BatteryInfo info = new BatteryInfo(); - info.batteryPercentString = "3%"; - assertThat(PowerUsageSummary.getDashboardLabel(mRealContext, info)) - .isEqualTo(info.batteryPercentString); - - info.remainingLabel = "Phone will shut down soon"; - assertThat(PowerUsageSummary.getDashboardLabel(mRealContext, info)) - .isEqualTo("3% - Phone will shut down soon"); - } - public static class TestFragment extends PowerUsageSummary { private Context mContext; diff --git a/tests/robotests/src/com/android/settings/fuelgauge/TopLevelBatteryPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/TopLevelBatteryPreferenceControllerTest.java new file mode 100644 index 00000000000..b1bc074eb50 --- /dev/null +++ b/tests/robotests/src/com/android/settings/fuelgauge/TopLevelBatteryPreferenceControllerTest.java @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2018 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.fuelgauge; + +import static com.android.settings.fuelgauge.TopLevelBatteryPreferenceController.getDashboardLabel; + +import static com.google.common.truth.Truth.assertThat; + +import android.content.Context; + +import com.android.settings.testutils.SettingsRobolectricTestRunner; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.robolectric.RuntimeEnvironment; + +@RunWith(SettingsRobolectricTestRunner.class) +public class TopLevelBatteryPreferenceControllerTest { + + private Context mContext; + + @Before + public void setUp() { + mContext = RuntimeEnvironment.application; + } + + @Test + public void getDashboardLabel_returnsCorrectLabel() { + BatteryInfo info = new BatteryInfo(); + info.batteryPercentString = "3%"; + assertThat(getDashboardLabel(mContext, info)) + .isEqualTo(info.batteryPercentString); + + info.remainingLabel = "Phone will shut down soon"; + assertThat(getDashboardLabel(mContext, info)) + .isEqualTo("3% - Phone will shut down soon"); + } +} diff --git a/tests/robotests/src/com/android/settings/security/SecuritySettingsTest.java b/tests/robotests/src/com/android/settings/security/TopLevelSecurityPreferenceControllerTest.java similarity index 66% rename from tests/robotests/src/com/android/settings/security/SecuritySettingsTest.java rename to tests/robotests/src/com/android/settings/security/TopLevelSecurityPreferenceControllerTest.java index f3cc4593ff5..17ba6d5f3f2 100644 --- a/tests/robotests/src/com/android/settings/security/SecuritySettingsTest.java +++ b/tests/robotests/src/com/android/settings/security/TopLevelSecurityPreferenceControllerTest.java @@ -17,7 +17,6 @@ package com.android.settings.security; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoMoreInteractions; import static org.mockito.Mockito.when; import android.content.Context; @@ -26,7 +25,6 @@ import android.hardware.face.FaceManager; import android.hardware.fingerprint.FingerprintManager; import com.android.settings.R; -import com.android.settings.dashboard.SummaryLoader; import com.android.settings.testutils.SettingsRobolectricTestRunner; import org.junit.Before; @@ -37,17 +35,15 @@ import org.mockito.Mock; import org.mockito.MockitoAnnotations; @RunWith(SettingsRobolectricTestRunner.class) -public class SecuritySettingsTest { +public class TopLevelSecurityPreferenceControllerTest { @Mock(answer = Answers.RETURNS_DEEP_STUBS) private Context mContext; @Mock - private SummaryLoader mSummaryLoader; - @Mock private FingerprintManager mFingerprintManager; @Mock private FaceManager mFaceManager; - private SecuritySettings.SummaryProvider mSummaryProvider; + private TopLevelSecurityEntryPreferenceController mController; @Before public void setUp() { @@ -56,87 +52,80 @@ public class SecuritySettingsTest { .thenReturn(mFingerprintManager); when(mContext.getSystemService(Context.FACE_SERVICE)) .thenReturn(mFaceManager); - mSummaryProvider = new SecuritySettings.SummaryProvider(mContext, mSummaryLoader); + mController = new TopLevelSecurityEntryPreferenceController(mContext, "test_key"); } @Test - public void testSummaryProvider_notListening() { - mSummaryProvider.setListening(false); - - verifyNoMoreInteractions(mSummaryLoader); - } - - @Test - public void testSummaryProvider_hasFace_hasStaticSummary() { + public void geSummary_hasFace_hasStaticSummary() { when(mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FACE)) .thenReturn(true); when(mFaceManager.isHardwareDetected()).thenReturn(true); - mSummaryProvider.setListening(true); + mController.getSummary(); - verify(mContext).getString(R.string.security_dashboard_summary_face); + verify(mContext).getText(R.string.security_dashboard_summary_face); } @Test - public void testSummaryProvider_hasFingerPrint_hasStaticSummary() { + public void geSummary_hasFingerPrint_hasStaticSummary() { when(mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FACE)) .thenReturn(false); when(mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FINGERPRINT)) .thenReturn(true); when(mFingerprintManager.isHardwareDetected()).thenReturn(true); - mSummaryProvider.setListening(true); + mController.getSummary(); - verify(mContext).getString(R.string.security_dashboard_summary); + verify(mContext).getText(R.string.security_dashboard_summary); } @Test - public void testSummaryProvider_noFpFeature_shouldSetSummaryWithNoBiometrics() { + public void geSummary_noFpFeature_shouldSetSummaryWithNoBiometrics() { when(mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FINGERPRINT)) .thenReturn(false); when(mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FACE)) .thenReturn(false); - mSummaryProvider.setListening(true); + mController.getSummary(); - verify(mContext).getString(R.string.security_dashboard_summary_no_fingerprint); + verify(mContext).getText(R.string.security_dashboard_summary_no_fingerprint); } @Test - public void testSummaryProvider_noFpHardware_shouldSetSummaryWithNoBiometrics() { + public void geSummary_noFpHardware_shouldSetSummaryWithNoBiometrics() { when(mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FACE)) .thenReturn(false); when(mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FINGERPRINT)) .thenReturn(true); when(mFingerprintManager.isHardwareDetected()).thenReturn(false); - mSummaryProvider.setListening(true); + mController.getSummary(); - verify(mContext).getString(R.string.security_dashboard_summary_no_fingerprint); + verify(mContext).getText(R.string.security_dashboard_summary_no_fingerprint); } @Test - public void testSummaryProvider_noFaceFeature_shouldSetSummaryWithNoBiometrics() { + public void geSummary_noFaceFeature_shouldSetSummaryWithNoBiometrics() { when(mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FINGERPRINT)) .thenReturn(false); when(mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FACE)) .thenReturn(false); - mSummaryProvider.setListening(true); + mController.getSummary(); - verify(mContext).getString(R.string.security_dashboard_summary_no_fingerprint); + verify(mContext).getText(R.string.security_dashboard_summary_no_fingerprint); } @Test - public void testSummaryProvider_noFaceHardware_shouldSetSummaryWithNoBiometrics() { + public void geSummary_noFaceHardware_shouldSetSummaryWithNoBiometrics() { when(mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FACE)) .thenReturn(true); when(mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FINGERPRINT)) .thenReturn(false); when(mFaceManager.isHardwareDetected()).thenReturn(false); - mSummaryProvider.setListening(true); + mController.getSummary(); - verify(mContext).getString(R.string.security_dashboard_summary_no_fingerprint); + verify(mContext).getText(R.string.security_dashboard_summary_no_fingerprint); } }