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

Commit 41baba14 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix NPE in InstantAppButtonsPreferenceController"

parents d9c312d5 8f7edfa1
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -112,11 +112,12 @@ public class InstantAppButtonsPreferenceController extends BasePreferenceControl
    @Override
    public void onPrepareOptionsMenu(Menu menu) {
        mInstallMenu = menu.findItem(AppInfoDashboardFragment.INSTALL_INSTANT_APP_MENU);
        final Intent appStoreIntent = AppStoreUtil.getAppStoreLink(mContext, mPackageName);
        if (appStoreIntent == null) {
        if (mInstallMenu != null) {
            if (AppStoreUtil.getAppStoreLink(mContext, mPackageName) == null) {
                mInstallMenu.setEnabled(false);
            }
        }
    }

    @Override
    public void onClick(DialogInterface dialog, int which) {
+9 −0
Original line number Diff line number Diff line
@@ -179,6 +179,15 @@ public class InstantAppButtonsPreferenceControllerTest {
        verify(menuItem, never()).setEnabled(false);
    }

    @Test
    public void onPrepareOptionsMenu_installMenuNotFound_shoulNotCrash() {
        final Menu menu = mock(Menu.class);

        mController.onPrepareOptionsMenu(menu);

        // no crash
    }

    @Test
    public void onOptionsItemSelected_shouldOpenAppStore() {
        final ResolveInfo resolveInfo = mock(ResolveInfo.class);