Merge "Improve Night Light suggestion criterion" into pi-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
981569f530
@@ -162,46 +162,6 @@ public class SuggestionFeatureProviderImplTest {
|
||||
assertThat(suggestions).hasSize(3);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void hasUsedNightDisplay_returnsFalse_byDefault() {
|
||||
assertThat(mProvider.hasUsedNightDisplay(mContext)).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void hasUsedNightDisplay_returnsTrue_ifPreviouslyActivatedAndManual() {
|
||||
Secure.putString(mContext.getContentResolver(), Secure.NIGHT_DISPLAY_LAST_ACTIVATED_TIME,
|
||||
LocalDateTime.now().toString());
|
||||
Secure.putInt(mContext.getContentResolver(), Secure.NIGHT_DISPLAY_AUTO_MODE, 1);
|
||||
assertThat(mProvider.hasUsedNightDisplay(mContext)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nightDisplaySuggestion_isCompleted_ifPreviouslyActivated() {
|
||||
Secure.putString(mContext.getContentResolver(), Secure.NIGHT_DISPLAY_LAST_ACTIVATED_TIME,
|
||||
LocalDateTime.now().toString());
|
||||
final ComponentName componentName =
|
||||
new ComponentName(mContext, NightDisplaySuggestionActivity.class);
|
||||
assertThat(mProvider.isSuggestionComplete(mContext, componentName)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nightDisplaySuggestion_isCompleted_ifNonManualMode() {
|
||||
Secure.putInt(mContext.getContentResolver(), Secure.NIGHT_DISPLAY_AUTO_MODE, 1);
|
||||
final ComponentName componentName =
|
||||
new ComponentName(mContext, NightDisplaySuggestionActivity.class);
|
||||
assertThat(mProvider.isSuggestionComplete(mContext, componentName)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nightDisplaySuggestion_isCompleted_ifPreviouslyCleared() {
|
||||
Secure.putString(mContext.getContentResolver(), Secure.NIGHT_DISPLAY_LAST_ACTIVATED_TIME,
|
||||
null);
|
||||
Secure.putInt(mContext.getContentResolver(), Secure.NIGHT_DISPLAY_AUTO_MODE, 1);
|
||||
final ComponentName componentName =
|
||||
new ComponentName(mContext, NightDisplaySuggestionActivity.class);
|
||||
assertThat(mProvider.isSuggestionComplete(mContext, componentName)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nightDisplaySuggestion_isNotCompleted_byDefault() {
|
||||
final ComponentName componentName =
|
||||
|
@@ -0,0 +1,61 @@
|
||||
package com.android.settings.display;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import android.app.Application;
|
||||
import android.content.ComponentName;
|
||||
import android.provider.Settings.Secure;
|
||||
import com.android.internal.app.ColorDisplayController;
|
||||
import com.android.settings.Settings.NightDisplaySuggestionActivity;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
public class NightDisplayPreferenceControllerTest {
|
||||
|
||||
private NightDisplayPreferenceController mPreferenceController;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
mPreferenceController = new NightDisplayPreferenceController(RuntimeEnvironment.application);
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
mPreferenceController = null;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nightDisplaySuggestion_isNotCompleted_ifAutoModeDisabled() {
|
||||
final Application context = RuntimeEnvironment.application;
|
||||
Secure.putInt(context.getContentResolver(),
|
||||
Secure.NIGHT_DISPLAY_AUTO_MODE, ColorDisplayController.AUTO_MODE_DISABLED);
|
||||
final ComponentName componentName =
|
||||
new ComponentName(context, NightDisplaySuggestionActivity.class);
|
||||
assertThat(mPreferenceController.isSuggestionComplete(context)).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nightDisplaySuggestion_isCompleted_ifAutoModeCustom() {
|
||||
final Application context = RuntimeEnvironment.application;
|
||||
Secure.putInt(context.getContentResolver(),
|
||||
Secure.NIGHT_DISPLAY_AUTO_MODE, ColorDisplayController.AUTO_MODE_CUSTOM);
|
||||
final ComponentName componentName =
|
||||
new ComponentName(context, NightDisplaySuggestionActivity.class);
|
||||
assertThat(mPreferenceController.isSuggestionComplete(context)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nightDisplaySuggestion_isCompleted_ifAutoModeTwilight() {
|
||||
final Application context = RuntimeEnvironment.application;
|
||||
Secure.putInt(context.getContentResolver(),
|
||||
Secure.NIGHT_DISPLAY_AUTO_MODE, ColorDisplayController.AUTO_MODE_TWILIGHT);
|
||||
final ComponentName componentName =
|
||||
new ComponentName(context, NightDisplaySuggestionActivity.class);
|
||||
assertThat(mPreferenceController.isSuggestionComplete(context)).isTrue();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user