Adds the Clear App dialog for Instant Apps
Adds a confirmation dialog for the user when tapping clear app. From this dialog the user can either cancel, or confirm they want to clear the app. Test: make RunSettingsRoboTests Bug: 36536695 Change-Id: Idffcf5ef318578ae2e075ea2cbb35323d41acade
This commit is contained in:
@@ -18,6 +18,7 @@ package com.android.settings.applications;
|
||||
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.admin.DevicePolicyManager;
|
||||
import android.content.Context;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
@@ -48,7 +49,9 @@ import org.robolectric.annotation.Config;
|
||||
import org.robolectric.util.ReflectionHelpers;
|
||||
|
||||
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.anyString;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
@@ -222,6 +225,20 @@ public final class InstalledAppDetailsTest {
|
||||
verify(forceStopButton).setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void instantApps_buttonControllerHandlesDialog() {
|
||||
InstantAppButtonsController mockController = mock(InstantAppButtonsController.class);
|
||||
ReflectionHelpers.setField(
|
||||
mAppDetail, "mInstantAppButtonsController", mockController);
|
||||
// Make sure first that button controller is not called for supported dialog id
|
||||
AlertDialog mockDialog = mock(AlertDialog.class);
|
||||
when(mockController.createDialog(InstantAppButtonsController.DLG_CLEAR_APP))
|
||||
.thenReturn(mockDialog);
|
||||
assertThat(mAppDetail.createDialog(InstantAppButtonsController.DLG_CLEAR_APP, 0))
|
||||
.isEqualTo(mockDialog);
|
||||
verify(mockController).createDialog(InstantAppButtonsController.DLG_CLEAR_APP);
|
||||
}
|
||||
|
||||
// A helper class for testing the InstantAppButtonsController - it lets us look up the
|
||||
// preference associated with a key for instant app buttons and get back a mock
|
||||
// LayoutPreference (to avoid a null pointer exception).
|
||||
@@ -261,8 +278,8 @@ public final class InstalledAppDetailsTest {
|
||||
FakeFeatureFactory.setupForTest(mContext);
|
||||
FakeFeatureFactory factory =
|
||||
(FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
|
||||
when(factory.applicationFeatureProvider.newInstantAppButtonsController(any(),
|
||||
any())).thenReturn(buttonsController);
|
||||
when(factory.applicationFeatureProvider.newInstantAppButtonsController(
|
||||
any(), any(), any())).thenReturn(buttonsController);
|
||||
|
||||
fragment.maybeAddInstantAppButtons();
|
||||
verify(buttonsController).setPackageName(anyString());
|
||||
|
Reference in New Issue
Block a user