Enforce min value on panel slices slider

We did not set the min value on slider slices when converting them
from preference to slices, which makes the slices all have min 0.
However, there are some slider which should have min value greater
than 0, for example, call and alarm.

We should get the min value and apply it to slider slice to make it
consistent with what we have in settings pref.

Test: Manual verification
Test: make -j40 RunSettingRobotests
Test: atest VolumeSeekBarPreferenceControllerTest
Fixes: 130439216
Fixes: 130358208
Change-Id: Ib4399c36c7da3ac41a6d46a6c150f0ec1b9b0b0f
This commit is contained in:
lindatseng
2019-04-15 15:51:07 -07:00
committed by Linda Tseng
parent 96b534951c
commit fadedb321c
14 changed files with 108 additions and 30 deletions

View File

@@ -41,7 +41,8 @@ public class SettingsSliderPreferenceControllerTest {
"key");
mPreference.setContinuousUpdates(true);
mPreference.setMax(mSliderController.getMaxSteps());
mPreference.setMin(mSliderController.getMin());
mPreference.setMax(mSliderController.getMax());
}
@Test
@@ -89,10 +90,15 @@ public class SettingsSliderPreferenceControllerTest {
}
@Override
public int getMaxSteps() {
public int getMax() {
return MAX_STEPS;
}
@Override
public int getMin() {
return 0;
}
@Override
public int getAvailabilityStatus() {
return AVAILABLE;

View File

@@ -88,10 +88,15 @@ public class SliderPreferenceControllerTest {
}
@Override
public int getMaxSteps() {
public int getMax() {
return MAX_STEPS;
}
@Override
public int getMin() {
return 0;
}
@Override
public int getAvailabilityStatus() {
return AVAILABLE;

View File

@@ -121,7 +121,12 @@ public class AdjustVolumeRestrictedPreferenceControllerTest {
}
@Override
public int getMaxSteps() {
public int getMax() {
return 0;
}
@Override
public int getMin() {
return 0;
}
}

View File

@@ -122,17 +122,31 @@ public class RemoteVolumePreferenceControllerTest {
}
@Test
public void getMaxSteps_controllerNull_returnZero() {
public void getMinValue_controllerNull_returnZero() {
mController.mMediaController = null;
assertThat(mController.getMaxSteps()).isEqualTo(0);
assertThat(mController.getMin()).isEqualTo(0);
}
@Test
public void getMaxSteps_controllerExists_returnValue() {
public void getMinValue_controllerExists_returnValue() {
mController.mMediaController = mMediaController;
assertThat(mController.getMaxSteps()).isEqualTo(MAX_POS);
assertThat(mController.getMin()).isEqualTo(0);
}
@Test
public void getMaxValue_controllerNull_returnZero() {
mController.mMediaController = null;
assertThat(mController.getMax()).isEqualTo(0);
}
@Test
public void getMaxValue_controllerExists_returnValue() {
mController.mMediaController = mMediaController;
assertThat(mController.getMax()).isEqualTo(MAX_POS);
}
@Test

View File

@@ -106,8 +106,10 @@ public class VolumeSeekBarPreferenceControllerTest {
public void sliderMethods_handleNullPreference() {
when(mHelper.getStreamVolume(mController.getAudioStream())).thenReturn(4);
when(mHelper.getMaxVolume(mController.getAudioStream())).thenReturn(10);
when(mHelper.getMinVolume(mController.getAudioStream())).thenReturn(1);
assertThat(mController.getMaxSteps()).isEqualTo(10);
assertThat(mController.getMax()).isEqualTo(10);
assertThat(mController.getMin()).isEqualTo(1);
assertThat(mController.getSliderPosition()).isEqualTo(4);
mController.setSliderPosition(9);
@@ -123,11 +125,19 @@ public class VolumeSeekBarPreferenceControllerTest {
}
@Test
public void getMaxSteps_passesAlongValue() {
public void getMaxValue_passesAlongValue() {
when(mPreference.getMax()).thenReturn(6);
mController.displayPreference(mScreen);
assertThat(mController.getMaxSteps()).isEqualTo(6);
assertThat(mController.getMax()).isEqualTo(6);
}
@Test
public void getMinValue_passesAlongValue() {
when(mPreference.getMin()).thenReturn(1);
mController.displayPreference(mScreen);
assertThat(mController.getMin()).isEqualTo(1);
}
@Test

View File

@@ -191,8 +191,8 @@ public class SliceBroadcastReceiverTest {
.build();
final ContentResolver resolver = mock(ContentResolver.class);
doReturn(resolver).when(mContext).getContentResolver();
final int position = FakeSliderController.MAX_STEPS - 1;
final int oldPosition = FakeSliderController.MAX_STEPS;
final int position = FakeSliderController.MAX_VALUE - 1;
final int oldPosition = FakeSliderController.MAX_VALUE;
mSearchFeatureProvider.getSearchIndexableResources().getProviderValues().clear();
insertSpecialCase(FakeSliderController.class, key);
@@ -310,8 +310,8 @@ public class SliceBroadcastReceiverTest {
// Insert Fake Slider into Database
final String key = "key";
final int position = FakeSliderController.MAX_STEPS - 1;
final int oldPosition = FakeSliderController.MAX_STEPS;
final int position = FakeSliderController.MAX_VALUE - 1;
final int oldPosition = FakeSliderController.MAX_VALUE;
mSearchFeatureProvider.getSearchIndexableResources().getProviderValues().clear();
insertSpecialCase(FakeSliderController.class, key);

View File

@@ -25,7 +25,7 @@ public class FakeSliderController extends SliderPreferenceController {
public static final String AVAILABILITY_KEY = "fake_slider_availability_key";
public static final int MAX_STEPS = 9;
public static final int MAX_VALUE = 9;
private static final String SETTING_KEY = "fake_slider_key";
@@ -44,8 +44,13 @@ public class FakeSliderController extends SliderPreferenceController {
}
@Override
public int getMaxSteps() {
return MAX_STEPS;
public int getMax() {
return MAX_VALUE;
}
@Override
public int getMin() {
return 0;
}
@Override