Merge changes I62c58967,I1dd57fa2 am: 20e39131c9 am: 72b557ac6a

Original change: https://android-review.googlesource.com/c/platform/packages/apps/Settings/+/1593774

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I216766fc245cdefacda920dcdde56c0d50f6d6b6
This commit is contained in:
Treehugger Robot
2021-02-18 17:09:56 +00:00
committed by Automerger Merge Worker
5 changed files with 10 additions and 34 deletions

View File

@@ -39,7 +39,6 @@ import android.content.pm.ResolveInfo;
import android.content.pm.UserInfo;
import android.content.res.Resources;
import android.net.ConnectivityManager;
import android.net.ProxyInfo;
import android.net.VpnManager;
import android.os.UserHandle;
import android.os.UserManager;
@@ -224,16 +223,6 @@ public class EnterprisePrivacyFeatureProviderImplTest {
assertThat(mProvider.isAlwaysOnVpnSetInManagedProfile()).isTrue();
}
@Test
public void testIsGlobalHttpProxySet() {
when(mConnectivityManger.getGlobalProxy()).thenReturn(null);
assertThat(mProvider.isGlobalHttpProxySet()).isFalse();
when(mConnectivityManger.getGlobalProxy())
.thenReturn(ProxyInfo.buildDirectProxy("localhost", 123));
assertThat(mProvider.isGlobalHttpProxySet()).isTrue();
}
@Test
public void testGetMaximumFailedPasswordsForWipeInCurrentUser() {
when(mDevicePolicyManager.getDeviceOwnerComponentOnCallingUser()).thenReturn(null);

View File

@@ -21,11 +21,11 @@ import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.when;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.ProxyInfo;
import androidx.preference.Preference;
import com.android.settings.testutils.FakeFeatureFactory;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -41,25 +41,23 @@ public class GlobalHttpProxyPreferenceControllerTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
private Context mContext;
private FakeFeatureFactory mFeatureFactory;
@Mock
private ConnectivityManager mCm;
private GlobalHttpProxyPreferenceController mController;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mFeatureFactory = FakeFeatureFactory.setupForTest();
mController = new GlobalHttpProxyPreferenceController(mContext);
}
@Test
public void testIsAvailable() {
when(mFeatureFactory.enterprisePrivacyFeatureProvider.isGlobalHttpProxySet())
.thenReturn(false);
when(mCm.getGlobalProxy()).thenReturn(null);
assertThat(mController.isAvailable()).isFalse();
when(mFeatureFactory.enterprisePrivacyFeatureProvider.isGlobalHttpProxySet())
.thenReturn(true);
when(mCm.getGlobalProxy()).thenReturn(ProxyInfo.buildDirectProxy("localhost", 123));
assertThat(mController.isAvailable()).isTrue();
}