Merge "Don't show suggestion slice if 'Screen attention' is already on" into qt-qpr1-dev

am: 7933af0273

Change-Id: Ibb750cc10763ade05e3f611a22e602ea3ebe7d5e
This commit is contained in:
Yi Jiang
2019-08-12 18:41:16 -07:00
committed by android-build-merger
2 changed files with 31 additions and 3 deletions

View File

@@ -32,6 +32,7 @@ import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.provider.Settings;
import androidx.slice.Slice;
import androidx.slice.SliceProvider;
@@ -65,6 +66,7 @@ public class ContextualAdaptiveSleepSliceTest {
mContext = spy(RuntimeEnvironment.application);
mContextualAdaptiveSleepSlice = spy(new ContextualAdaptiveSleepSlice(mContext));
Settings.System.putInt(mContext.getContentResolver(), Settings.System.ADAPTIVE_SLEEP, 0);
doReturn(mPackageManager).when(mContext).getPackageManager();
doReturn(mSharedPreferences).when(mContext).getSharedPreferences(eq(PREF), anyInt());
doReturn(true).when(mContextualAdaptiveSleepSlice).isSettingsAvailable();
@@ -112,4 +114,20 @@ public class ContextualAdaptiveSleepSliceTest {
assertThat(slice).isNull();
}
@Test
public void getSlice_ShowIfNotTurnedOn() {
final Slice slice = mContextualAdaptiveSleepSlice.getSlice();
assertThat(slice).isNotNull();
}
@Test
public void getSlice_DoNotShowIfTurnedOn() {
Settings.System.putInt(mContext.getContentResolver(), Settings.System.ADAPTIVE_SLEEP, 1);
final Slice slice = mContextualAdaptiveSleepSlice.getSlice();
assertThat(slice).isNull();
}
}