Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 446ba160 authored by govenliu's avatar govenliu
Browse files

[Wi-Fi] Use getUriHelpString() result to judge if show the Openroaming help button.

The Openroaming help button should show only when the getHelpUriString() value is not null.

Bug: 146669261
Test: Adjust unit test cases:
      1. make RunSettingsRoboTests ROBOTEST_FILTER=WifiEntryPreferenceTest
      2. make RunSettingsRoboTests ROBOTEST_FILTER=WifiSettings2Test
Change-Id: I3d59162b782d5aca5251a42009eac95432d446d9
parent 03aa3216
Loading
Loading
Loading
Loading
+2 −3
Original line number Original line Diff line number Diff line
@@ -102,12 +102,11 @@ public class WifiEntryPreference extends Preference implements WifiEntry.WifiEnt
        // Turn off divider
        // Turn off divider
        view.findViewById(R.id.two_target_divider).setVisibility(View.INVISIBLE);
        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 ImageButton imageButton = (ImageButton) view.findViewById(R.id.icon_button);
        final ImageView frictionImageView = (ImageView) view.findViewById(
        final ImageView frictionImageView = (ImageView) view.findViewById(
                R.id.friction_icon);
                R.id.friction_icon);
        if (mWifiEntry.canManageSubscription() && !mWifiEntry.isSaved()
        if (mWifiEntry.getHelpUriString() != null
                && !mWifiEntry.isSubscription()
                && mWifiEntry.getConnectedState() == WifiEntry.CONNECTED_STATE_DISCONNECTED) {
                && mWifiEntry.getConnectedState() == WifiEntry.CONNECTED_STATE_DISCONNECTED) {
            final Drawable drawablehelp = getDrawable(R.drawable.ic_help);
            final Drawable drawablehelp = getDrawable(R.drawable.ic_help);
            drawablehelp.setTintList(
            drawablehelp.setTintList(
+6 −5
Original line number Original line Diff line number Diff line
@@ -64,7 +64,7 @@ public class WifiEntryPreferenceTest {


    private static final String MOCK_TITLE = "title";
    private static final String MOCK_TITLE = "title";
    private static final String MOCK_SUMMARY = "summary";
    private static final String MOCK_SUMMARY = "summary";

    private static final String FAKE_URI_STRING = "fakeuri";


    @Before
    @Before
    public void setUp() {
    public void setUp() {
@@ -155,22 +155,23 @@ public class WifiEntryPreferenceTest {
    }
    }


    @Test
    @Test
    public void canManageSubscription_shouldSetImageButtonVisible() {
    public void notNull_whenGetHelpUriString_shouldSetImageButtonVisible() {
        when(mMockWifiEntry.canManageSubscription()).thenReturn(true);
        when(mMockWifiEntry.getHelpUriString()).thenReturn(FAKE_URI_STRING);
        final WifiEntryPreference pref =
        final WifiEntryPreference pref =
                new WifiEntryPreference(mContext, mMockWifiEntry, mMockIconInjector);
                new WifiEntryPreference(mContext, mMockWifiEntry, mMockIconInjector);
        final LayoutInflater inflater = LayoutInflater.from(mContext);
        final LayoutInflater inflater = LayoutInflater.from(mContext);
        final View view = inflater.inflate(pref.getLayoutResource(), new LinearLayout(mContext),
        final View view = inflater.inflate(pref.getLayoutResource(), new LinearLayout(mContext),
                false);
                false);
        final PreferenceViewHolder holder = PreferenceViewHolder.createInstanceForTests(view);
        final PreferenceViewHolder holder = PreferenceViewHolder.createInstanceForTests(view);

        pref.onBindViewHolder(holder);
        pref.onBindViewHolder(holder);


        assertThat(view.findViewById(R.id.icon_button).getVisibility()).isEqualTo(View.VISIBLE);
        assertThat(view.findViewById(R.id.icon_button).getVisibility()).isEqualTo(View.VISIBLE);
    }
    }


    @Test
    @Test
    public void helpButton_whenCanManageSubscription_shouldSetCorrectContentDescription() {
    public void helpButton_whenGetHelpUriStringNotNull_shouldSetCorrectContentDescription() {
        when(mMockWifiEntry.canManageSubscription()).thenReturn(true);
        when(mMockWifiEntry.getHelpUriString()).thenReturn(FAKE_URI_STRING);
        final WifiEntryPreference pref =
        final WifiEntryPreference pref =
                new WifiEntryPreference(mContext, mMockWifiEntry, mMockIconInjector);
                new WifiEntryPreference(mContext, mMockWifiEntry, mMockIconInjector);
        final LayoutInflater inflater = LayoutInflater.from(mContext);
        final LayoutInflater inflater = LayoutInflater.from(mContext);