Snap for 6379507 from 11bc56b99d to mainline-release
Change-Id: I6edc2939fee4c139a36b1c6cb70c362a967c1c99
This commit is contained in:
@@ -1,31 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Copyright (C) 2020 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.
|
||||
-->
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:background="@android:color/transparent"
|
||||
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
|
||||
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/empty_view_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge" />
|
||||
</LinearLayout>
|
||||
@@ -3032,7 +3032,7 @@
|
||||
<!-- About phone screen, status item label [CHAR LIMIT=40] -->
|
||||
<string name="firmware_version">Android version</string>
|
||||
<!-- About phone screen, status item label [CHAR LIMIT=60] -->
|
||||
<string name="security_patch">Android security patch level</string>
|
||||
<string name="security_patch">Android security update</string>
|
||||
<!-- About phone screen, status item label [CHAR LIMIT=40] -->
|
||||
<string name="model_info">Model</string>
|
||||
<!-- About phone screen, status item summary [CHAR LIMIT=40] -->
|
||||
@@ -7181,8 +7181,6 @@
|
||||
<string name="help_url_double_tap_screen" translatable="false"></string>
|
||||
<string name="help_url_account_detail" translatable="false"></string>
|
||||
<string name="help_url_icc_lock" translatable="false"></string>
|
||||
<!-- Help URI, ManageSubscription [DO NOT TRANSLATE] -->
|
||||
<string name="help_url_manage_wifi_subscription" translatable="false"></string>
|
||||
|
||||
<string name="help_uri_process_stats_summary" translatable="false"></string>
|
||||
<string name="help_uri_process_stats_apps" translatable="false"></string>
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.android.settings.development.storage;
|
||||
|
||||
import android.app.ActionBar;
|
||||
import android.app.ListActivity;
|
||||
import android.app.blob.BlobInfo;
|
||||
import android.app.blob.BlobStoreManager;
|
||||
@@ -30,7 +31,6 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
@@ -41,7 +41,6 @@ import com.android.settings.R;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
// TODO: have this class extend DashboardFragment for consistency
|
||||
public class BlobInfoListView extends ListActivity {
|
||||
private static final String TAG = "BlobInfoListView";
|
||||
|
||||
@@ -60,6 +59,17 @@ public class BlobInfoListView extends ListActivity {
|
||||
|
||||
mAdapter = new BlobListAdapter(this);
|
||||
setListAdapter(mAdapter);
|
||||
|
||||
final ActionBar actionBar = getActionBar();
|
||||
if (actionBar != null) {
|
||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onNavigateUp() {
|
||||
finish();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -91,14 +101,6 @@ public class BlobInfoListView extends ListActivity {
|
||||
}
|
||||
}
|
||||
|
||||
private View getEmptyView() {
|
||||
final View emptyView = mInflater.inflate(R.layout.shared_data_empty_list_view,
|
||||
(ViewGroup) getListView().getRootView());
|
||||
final TextView emptyText = emptyView.findViewById(R.id.empty_view_text);
|
||||
emptyText.setText(R.string.shared_data_no_blobs_text);
|
||||
return emptyView;
|
||||
}
|
||||
|
||||
private void showDeleteBlobDialog(BlobInfo blob) {
|
||||
final AlertDialog dialog = new AlertDialog.Builder(mContext)
|
||||
.setMessage(R.string.shared_data_no_accessors_dialog_text)
|
||||
@@ -139,7 +141,7 @@ public class BlobInfoListView extends ListActivity {
|
||||
void updateList(List<BlobInfo> blobs) {
|
||||
clear();
|
||||
if (blobs.isEmpty()) {
|
||||
getListView().setEmptyView(getEmptyView());
|
||||
finish();
|
||||
} else {
|
||||
addAll(blobs);
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.android.settings.development.storage;
|
||||
|
||||
import android.app.ActionBar;
|
||||
import android.app.ListActivity;
|
||||
import android.app.blob.BlobInfo;
|
||||
import android.app.blob.BlobStoreManager;
|
||||
@@ -44,7 +45,6 @@ import com.android.settings.R;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
// TODO: have this class extend DashboardFragment for consistency
|
||||
public class LeaseInfoListView extends ListActivity {
|
||||
private static final String TAG = "LeaseInfoListView";
|
||||
|
||||
@@ -74,6 +74,17 @@ public class LeaseInfoListView extends ListActivity {
|
||||
getListView().addHeaderView(getHeaderView());
|
||||
getListView().addFooterView(getFooterView());
|
||||
getListView().setClickable(false);
|
||||
|
||||
final ActionBar actionBar = getActionBar();
|
||||
if (actionBar != null) {
|
||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onNavigateUp() {
|
||||
finish();
|
||||
return true;
|
||||
}
|
||||
|
||||
private LinearLayout getHeaderView() {
|
||||
|
||||
@@ -18,13 +18,20 @@ package com.android.settings.development.storage;
|
||||
|
||||
import android.app.blob.BlobStoreManager;
|
||||
import android.content.Context;
|
||||
import android.os.UserHandle;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.PreferenceControllerMixin;
|
||||
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
|
||||
|
||||
public class SharedDataPreferenceController extends DeveloperOptionsPreferenceController {
|
||||
import java.io.IOException;
|
||||
|
||||
public class SharedDataPreferenceController extends DeveloperOptionsPreferenceController
|
||||
implements PreferenceControllerMixin {
|
||||
private static final String TAG = "SharedDataPrefCtrl";
|
||||
private static final String SHARED_DATA = "shared_data";
|
||||
|
||||
private BlobStoreManager mBlobStoreManager;
|
||||
@@ -39,14 +46,18 @@ public class SharedDataPreferenceController extends DeveloperOptionsPreferenceCo
|
||||
return SHARED_DATA;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailable() {
|
||||
return mBlobStoreManager != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateState(Preference preference) {
|
||||
preference.setEnabled(mBlobStoreManager != null);
|
||||
// TODO: update summary to indicate why this preference isn't available
|
||||
try {
|
||||
final boolean showPref = mBlobStoreManager != null
|
||||
&& !mBlobStoreManager.queryBlobsForUser(UserHandle.CURRENT).isEmpty();
|
||||
preference.setEnabled(showPref);
|
||||
preference.setSummary(showPref ? R.string.shared_data_summary
|
||||
: R.string.shared_data_no_blobs_text);
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, "Unable to fetch blobs for current user: " + e.getMessage());
|
||||
preference.setEnabled(false);
|
||||
preference.setSummary(R.string.shared_data_no_blobs_text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL_OV
|
||||
import static com.android.settings.widget.RadioButtonPreferenceWithExtraWidget.EXTRA_WIDGET_VISIBILITY_GONE;
|
||||
import static com.android.settings.widget.RadioButtonPreferenceWithExtraWidget.EXTRA_WIDGET_VISIBILITY_SETTING;
|
||||
|
||||
import android.accessibilityservice.AccessibilityServiceInfo;
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@@ -273,18 +272,10 @@ public class SystemNavigationGestureSettings extends RadioButtonPickerFragment i
|
||||
}
|
||||
|
||||
private boolean isAnyServiceSupportAccessibilityButton() {
|
||||
final AccessibilityManager ams = (AccessibilityManager) getContext().getSystemService(
|
||||
Context.ACCESSIBILITY_SERVICE);
|
||||
final List<AccessibilityServiceInfo> services = ams.getEnabledAccessibilityServiceList(
|
||||
AccessibilityServiceInfo.FEEDBACK_ALL_MASK);
|
||||
|
||||
for (AccessibilityServiceInfo info : services) {
|
||||
if ((info.flags & AccessibilityServiceInfo.FLAG_REQUEST_ACCESSIBILITY_BUTTON) != 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
final AccessibilityManager ams = getContext().getSystemService(AccessibilityManager.class);
|
||||
final List<String> targets = ams.getAccessibilityShortcutTargets(
|
||||
AccessibilityManager.ACCESSIBILITY_BUTTON);
|
||||
return !targets.isEmpty();
|
||||
}
|
||||
|
||||
private boolean isNavBarMagnificationEnabled() {
|
||||
|
||||
@@ -25,6 +25,7 @@ import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.media.session.MediaController;
|
||||
import android.net.Uri;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.core.graphics.drawable.IconCompat;
|
||||
import androidx.slice.Slice;
|
||||
@@ -104,6 +105,10 @@ public class MediaOutputIndicatorSlice implements CustomSliceable {
|
||||
|
||||
@Override
|
||||
public void onNotifyChange(Intent i) {
|
||||
if (getWorker() == null) {
|
||||
Log.d(TAG, "onNotifyChange: Worker is null");
|
||||
return;
|
||||
}
|
||||
final MediaController mediaController = getWorker().getActiveLocalMediaController();
|
||||
final Intent intent = new Intent()
|
||||
.setPackage(Utils.SETTINGS_PACKAGE_NAME)
|
||||
|
||||
@@ -26,8 +26,6 @@ import android.telephony.TelephonyManager;
|
||||
import androidx.preference.ListPreference;
|
||||
import androidx.preference.Preference;
|
||||
|
||||
import com.android.settings.network.telephony.TelephonyConstants.TelephonyManagerConstants;
|
||||
|
||||
/**
|
||||
* Preference controller for "System Select"
|
||||
*/
|
||||
|
||||
@@ -176,7 +176,11 @@ public class AutoSelectPreferenceController extends TelephonyTogglePreferenceCon
|
||||
|
||||
private void dismissProgressBar() {
|
||||
if (mProgressDialog != null && mProgressDialog.isShowing()) {
|
||||
try {
|
||||
mProgressDialog.dismiss();
|
||||
} catch (IllegalArgumentException e) {
|
||||
// Ignore exception since the dialog will be gone anyway.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -259,7 +259,9 @@ public class MediaOutputPanel implements PanelContent, LocalMediaManager.DeviceC
|
||||
|
||||
@Override
|
||||
public void onPlaybackStateChanged(PlaybackState state) {
|
||||
if (mCallback != null && state.getState() != PlaybackState.STATE_PLAYING) {
|
||||
final int playState = state.getState();
|
||||
if (mCallback != null && (playState == PlaybackState.STATE_STOPPED
|
||||
|| playState == PlaybackState.STATE_PAUSED)) {
|
||||
mCallback.forceClose();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.android.settings.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
@@ -95,6 +96,7 @@ public class DisabledCheckBoxPreference extends CheckBoxPreference {
|
||||
if (title != null) {
|
||||
title.setSingleLine(false);
|
||||
title.setMaxLines(2);
|
||||
title.setEllipsize(TextUtils.TruncateAt.END);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -770,9 +770,9 @@ public class WifiSettings2 extends RestrictedSettingsFragment
|
||||
pref.setOrder(index++);
|
||||
pref.refresh();
|
||||
|
||||
if (wifiEntry.canManageSubscription()) {
|
||||
if (wifiEntry.getHelpUriString() != null) {
|
||||
pref.setOnButtonClickListener(preference -> {
|
||||
openSubscriptionHelpPage();
|
||||
openSubscriptionHelpPage(wifiEntry);
|
||||
});
|
||||
}
|
||||
mWifiEntryPreferenceCategory.addPreference(pref);
|
||||
@@ -1111,8 +1111,8 @@ public class WifiSettings2 extends RestrictedSettingsFragment
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
void openSubscriptionHelpPage() {
|
||||
final Intent intent = getHelpIntent(getContext());
|
||||
void openSubscriptionHelpPage(WifiEntry wifiEntry) {
|
||||
final Intent intent = getHelpIntent(getContext(), wifiEntry.getHelpUriString());
|
||||
if (intent != null) {
|
||||
try {
|
||||
startActivityForResult(intent, MANAGE_SUBSCRIPTION);
|
||||
@@ -1123,10 +1123,7 @@ public class WifiSettings2 extends RestrictedSettingsFragment
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
Intent getHelpIntent(Context context) {
|
||||
return HelpUtils.getHelpIntent(
|
||||
context,
|
||||
context.getString(R.string.help_url_manage_wifi_subscription),
|
||||
context.getClass().getName());
|
||||
Intent getHelpIntent(Context context, String helpUrlString) {
|
||||
return HelpUtils.getHelpIntent(context, helpUrlString, context.getClass().getName());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.android.settings.wifi.savedaccesspoints2;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.preference.Preference;
|
||||
@@ -83,9 +84,29 @@ public class SavedAccessPointsPreferenceController2 extends BasePreferenceContro
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* mPreferenceGroup is not in a RecyclerView. To keep TalkBack focus, this method should not
|
||||
* mPreferenceGroup.removeAll() then mPreferenceGroup.addPreference for mWifiEntries.
|
||||
*/
|
||||
private void updatePreference() {
|
||||
mPreferenceGroup.removeAll();
|
||||
// Remove the Preference of removed WifiEntry.
|
||||
final List<String> removedPreferenceKeys = new ArrayList<>();
|
||||
final int preferenceCount = mPreferenceGroup.getPreferenceCount();
|
||||
for (int i = 0; i < preferenceCount; i++) {
|
||||
final String key = mPreferenceGroup.getPreference(i).getKey();
|
||||
if (mWifiEntries.stream().filter(wifiEntry ->
|
||||
TextUtils.equals(key, wifiEntry.getKey())).count() == 0) {
|
||||
removedPreferenceKeys.add(key);
|
||||
}
|
||||
}
|
||||
for (String removedPreferenceKey : removedPreferenceKeys) {
|
||||
mPreferenceGroup.removePreference(
|
||||
mPreferenceGroup.findPreference(removedPreferenceKey));
|
||||
}
|
||||
|
||||
// Add the Preference of new added WifiEntry.
|
||||
for (WifiEntry wifiEntry : mWifiEntries) {
|
||||
if (mPreferenceGroup.findPreference(wifiEntry.getKey()) == null) {
|
||||
final WifiEntryPreference preference = new WifiEntryPreference(mContext, wifiEntry);
|
||||
preference.setKey(wifiEntry.getKey());
|
||||
preference.setOnPreferenceClickListener(this);
|
||||
@@ -94,3 +115,4 @@ public class SavedAccessPointsPreferenceController2 extends BasePreferenceContro
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,8 +22,11 @@ import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.app.blob.BlobInfo;
|
||||
import android.app.blob.BlobStoreManager;
|
||||
import android.app.blob.LeaseInfo;
|
||||
import android.content.Context;
|
||||
import android.os.UserHandle;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
@@ -38,6 +41,10 @@ import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.util.ReflectionHelpers;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
// TODO: add more detailed tests for the shared data screens
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class SharedDataPreferenceControllerTest {
|
||||
@@ -63,8 +70,11 @@ public class SharedDataPreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateState_BlobManagerIsNotNull_preferenceIsEnabled() {
|
||||
public void updateState_BlobManagerIsNotNullAndBlobsExist_preferenceIsEnabled()
|
||||
throws IOException {
|
||||
ReflectionHelpers.setField(mController, "mBlobStoreManager", mBlobStoreManager);
|
||||
when(mBlobStoreManager.queryBlobsForUser(UserHandle.CURRENT))
|
||||
.thenReturn(generateBlobList());
|
||||
mController.updateState(mPreference);
|
||||
|
||||
verify(mPreference).setEnabled(true);
|
||||
@@ -72,11 +82,38 @@ public class SharedDataPreferenceControllerTest {
|
||||
.isEqualTo(mContext.getString(R.string.shared_data_summary));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateState_BlobManagerIsNotNullButNoBlobsExist_preferenceIsDisabled() {
|
||||
ReflectionHelpers.setField(mController, "mBlobStoreManager", mBlobStoreManager);
|
||||
mController.updateState(mPreference);
|
||||
|
||||
verify(mPreference).setEnabled(false);
|
||||
assertThat(mPreference.getSummary())
|
||||
.isEqualTo(mContext.getString(R.string.shared_data_no_blobs_text));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateState_BlobManagerIsNull_preferenceIsDisabled() {
|
||||
ReflectionHelpers.setField(mController, "mBlobStoreManager", null);
|
||||
mController.updateState(mPreference);
|
||||
|
||||
verify(mPreference).setEnabled(false);
|
||||
assertThat(mPreference.getSummary())
|
||||
.isEqualTo(mContext.getString(R.string.shared_data_no_blobs_text));
|
||||
}
|
||||
|
||||
private List<BlobInfo> generateBlobList() {
|
||||
LeaseInfo one = new LeaseInfo("com.google.android.photos",
|
||||
System.currentTimeMillis(), -1, "test description");
|
||||
LeaseInfo two = new LeaseInfo("com.google.android.drive",
|
||||
System.currentTimeMillis(), -1, "test description 2");
|
||||
|
||||
List<LeaseInfo> accessors = new ArrayList<>();
|
||||
accessors.add(one);
|
||||
accessors.add(two);
|
||||
|
||||
final List<BlobInfo> tmp = new ArrayList<>();
|
||||
tmp.add(new BlobInfo(10, System.currentTimeMillis(), "testing blob 1", accessors));
|
||||
return tmp;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,9 @@ import static com.android.settings.slices.CustomSliceRegistry.MEDIA_OUTPUT_INDIC
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
@@ -190,6 +192,14 @@ public class MediaOutputIndicatorSliceTest {
|
||||
assertThat(metadata.isErrorSlice()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onNotifyChange_noWorker_doNothing() {
|
||||
sMediaOutputIndicatorWorker = null;
|
||||
mMediaOutputIndicatorSlice.onNotifyChange(new Intent());
|
||||
|
||||
verify(mContext, never()).startActivity(any());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onNotifyChange_withActiveLocalMedia_verifyIntentExtra() {
|
||||
when(mMediaController.getSessionToken()).thenReturn(mToken);
|
||||
|
||||
@@ -295,4 +295,19 @@ public class MediaOutputPanelTest {
|
||||
|
||||
verify(mCallback).forceClose();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onPlaybackStateChanged_stateFromPlayingToPaused_verifyCallForceClose() {
|
||||
mPanel.onStart();
|
||||
verify(mMediaController).registerCallback(mControllerCbs.capture());
|
||||
final MediaController.Callback controllerCallbacks = mControllerCbs.getValue();
|
||||
when(mPlaybackState.getState()).thenReturn(PlaybackState.STATE_PLAYING);
|
||||
controllerCallbacks.onPlaybackStateChanged(mPlaybackState);
|
||||
verify(mCallback, never()).forceClose();
|
||||
|
||||
when(mPlaybackState.getState()).thenReturn(PlaybackState.STATE_PAUSED);
|
||||
controllerCallbacks.onPlaybackStateChanged(mPlaybackState);
|
||||
|
||||
verify(mCallback).forceClose();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,6 +74,7 @@ import org.robolectric.shadows.ShadowToast;
|
||||
public class WifiSettings2Test {
|
||||
|
||||
private static final int NUM_NETWORKS = 4;
|
||||
private static final String FAKE_URI_STRING = "fakeuri";
|
||||
|
||||
@Mock
|
||||
private PowerManager mPowerManager;
|
||||
@@ -281,10 +282,12 @@ public class WifiSettings2Test {
|
||||
|
||||
@Test
|
||||
public void openSubscriptionHelpPage_shouldCallStartActivityForResult() {
|
||||
doReturn(new Intent()).when(mWifiSettings2).getHelpIntent(mContext);
|
||||
doReturn(new Intent()).when(mWifiSettings2).getHelpIntent(mContext, FAKE_URI_STRING);
|
||||
doNothing().when(mWifiSettings2).startActivityForResult(any(Intent.class), anyInt());
|
||||
final WifiEntry mockWifiEntry = mock(WifiEntry.class);
|
||||
when(mockWifiEntry.getHelpUriString()).thenReturn(FAKE_URI_STRING);
|
||||
|
||||
mWifiSettings2.openSubscriptionHelpPage();
|
||||
mWifiSettings2.openSubscriptionHelpPage(mockWifiEntry);
|
||||
|
||||
verify(mWifiSettings2, times(1)).startActivityForResult(any(), anyInt());
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ import static org.mockito.Matchers.anyInt;
|
||||
import static org.mockito.Matchers.anyObject;
|
||||
import static org.mockito.Mockito.doNothing;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.verify;
|
||||
@@ -43,9 +42,6 @@ import com.android.settings.R;
|
||||
import com.android.settings.testutils.shadow.ShadowDisclaimerItemFactory;
|
||||
import com.android.settings.testutils.shadow.ShadowFragment;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -53,9 +49,12 @@ import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Captor;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.annotation.Config;
|
||||
import org.robolectric.Robolectric;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.annotation.Config;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
@Config(shadows = {ShadowDisclaimerItemFactory.class, ShadowFragment.class})
|
||||
|
||||
@@ -103,4 +103,20 @@ public class SavedAccessPointsPreferenceController2Test {
|
||||
assertThat(prefs.size()).isEqualTo(1);
|
||||
assertThat(prefs.get(0).getTitle()).isEqualTo(title);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void displayPreference_noAccessPoint_shouldRemoveIt() {
|
||||
final String title = "ssid_title";
|
||||
final String key = "key";
|
||||
final WifiEntry mockWifiEntry = mock(WifiEntry.class);
|
||||
when(mockWifiEntry.getTitle()).thenReturn(title);
|
||||
when(mockWifiEntry.getKey()).thenReturn(key);
|
||||
final WifiEntryPreference preference = new WifiEntryPreference(mContext, mockWifiEntry);
|
||||
preference.setKey(key);
|
||||
mPreferenceCategory.addPreference(preference);
|
||||
|
||||
mController.displayPreference(mPreferenceScreen, new ArrayList<>());
|
||||
|
||||
assertThat(mPreferenceCategory.getPreferenceCount()).isEqualTo(0);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user