Merge "[Settings] enhancing data saver config control" into tm-qpr-dev am: 106fd86520
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/20419511 Change-Id: I5338c24812346b79068b1fee0c5ba98ff07eec33 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -18,9 +18,13 @@ package com.android.settings.applications.specialaccess;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.mockito.Mockito.spy;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
|
||||
import com.android.settings.R;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -34,23 +38,35 @@ import org.robolectric.annotation.Config;
|
||||
public class DataSaverControllerTest {
|
||||
|
||||
private Context mContext;
|
||||
private Resources mResources;
|
||||
private DataSaverController mController;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mContext = spy(RuntimeEnvironment.application.getApplicationContext());
|
||||
|
||||
mResources = spy(mContext.getResources());
|
||||
when(mContext.getResources()).thenReturn(mResources);
|
||||
|
||||
mController = new DataSaverController(mContext, "key");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDataSaver_byDefault_shouldBeShown() {
|
||||
when(mResources.getBoolean(R.bool.config_show_data_saver)).thenReturn(true);
|
||||
assertThat(mController.isAvailable()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Config(qualifiers = "mcc999")
|
||||
public void testDataSaver_ifDisabledByCarrier_shouldNotBeShown() {
|
||||
assertThat(mController.isAvailable()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDataSaver_ifDisabled_shouldNotBeShown() {
|
||||
when(mResources.getBoolean(R.bool.config_show_data_saver)).thenReturn(false);
|
||||
assertThat(mController.isAvailable()).isFalse();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user