Merge "[Wi-Fi] Use getUriHelpString() result to judge if show the Openroaming help button." into rvc-dev

This commit is contained in:
Goven Liu
2020-04-08 22:37:35 +00:00
committed by Android (Google) Code Review
2 changed files with 8 additions and 8 deletions

View File

@@ -102,12 +102,11 @@ public class WifiEntryPreference extends Preference implements WifiEntry.WifiEnt
// Turn off divider
view.findViewById(R.id.two_target_divider).setVisibility(View.INVISIBLE);
// Enable the icon button when this Entry is a canManageSubscription entry.
// Enable the icon button when the help string in this WifiEntry is not null.
final ImageButton imageButton = (ImageButton) view.findViewById(R.id.icon_button);
final ImageView frictionImageView = (ImageView) view.findViewById(
R.id.friction_icon);
if (mWifiEntry.canManageSubscription() && !mWifiEntry.isSaved()
&& !mWifiEntry.isSubscription()
if (mWifiEntry.getHelpUriString() != null
&& mWifiEntry.getConnectedState() == WifiEntry.CONNECTED_STATE_DISCONNECTED) {
final Drawable drawablehelp = getDrawable(R.drawable.ic_help);
drawablehelp.setTintList(

View File

@@ -64,7 +64,7 @@ public class WifiEntryPreferenceTest {
private static final String MOCK_TITLE = "title";
private static final String MOCK_SUMMARY = "summary";
private static final String FAKE_URI_STRING = "fakeuri";
@Before
public void setUp() {
@@ -155,22 +155,23 @@ public class WifiEntryPreferenceTest {
}
@Test
public void canManageSubscription_shouldSetImageButtonVisible() {
when(mMockWifiEntry.canManageSubscription()).thenReturn(true);
public void notNull_whenGetHelpUriString_shouldSetImageButtonVisible() {
when(mMockWifiEntry.getHelpUriString()).thenReturn(FAKE_URI_STRING);
final WifiEntryPreference pref =
new WifiEntryPreference(mContext, mMockWifiEntry, mMockIconInjector);
final LayoutInflater inflater = LayoutInflater.from(mContext);
final View view = inflater.inflate(pref.getLayoutResource(), new LinearLayout(mContext),
false);
final PreferenceViewHolder holder = PreferenceViewHolder.createInstanceForTests(view);
pref.onBindViewHolder(holder);
assertThat(view.findViewById(R.id.icon_button).getVisibility()).isEqualTo(View.VISIBLE);
}
@Test
public void helpButton_whenCanManageSubscription_shouldSetCorrectContentDescription() {
when(mMockWifiEntry.canManageSubscription()).thenReturn(true);
public void helpButton_whenGetHelpUriStringNotNull_shouldSetCorrectContentDescription() {
when(mMockWifiEntry.getHelpUriString()).thenReturn(FAKE_URI_STRING);
final WifiEntryPreference pref =
new WifiEntryPreference(mContext, mMockWifiEntry, mMockIconInjector);
final LayoutInflater inflater = LayoutInflater.from(mContext);