Merge "Add default value to inline payloads" into oc-dr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
5aca5f3aec
@@ -220,7 +220,7 @@ public class CursorToSearchResultConverterTest {
|
||||
final Intent intent = new Intent();
|
||||
intent.putExtra(intentKey, intentVal);
|
||||
final InlineSwitchPayload payload = new InlineSwitchPayload(uri, source, 1 /* onValue */,
|
||||
intent, true /* isDeviceSupported */);
|
||||
intent, true /* isDeviceSupported */, 0 /* defautValue */);
|
||||
|
||||
cursor.addRow(new Object[]{
|
||||
KEY.hashCode(), // Doc ID
|
||||
|
@@ -114,7 +114,7 @@ public class DatabaseRowTest {
|
||||
public void testRowWithInlinePayload_genericPayloadNotAdded() {
|
||||
final String URI = "test uri";
|
||||
final InlineSwitchPayload payload = new InlineSwitchPayload(URI, 0 /* mSettingSource */,
|
||||
1 /* onValue */, null /* intent */, true /* isDeviceSupported */);
|
||||
1 /* onValue */, null /* intent */, true /* isDeviceSupported */, 1 /* default */);
|
||||
mBuilder.setPayload(payload);
|
||||
final DatabaseRow row = generateRow();
|
||||
final InlineSwitchPayload unmarshalledPayload = ResultPayloadUtils
|
||||
@@ -133,7 +133,7 @@ public class DatabaseRowTest {
|
||||
intent.setComponent(component);
|
||||
|
||||
final InlineSwitchPayload payload = new InlineSwitchPayload(URI, 0 /* mSettingSource */,
|
||||
1 /* onValue */, intent, true /* isDeviceSupported */);
|
||||
1 /* onValue */, intent, true /* isDeviceSupported */, 1 /* default */);
|
||||
mBuilder.setPayload(payload);
|
||||
final DatabaseRow row = generateRow();
|
||||
final InlineSwitchPayload unmarshalledPayload = ResultPayloadUtils
|
||||
|
@@ -37,7 +37,7 @@ public class InlineListPayloadTest {
|
||||
intent.putExtra(intentKey, intentVal);
|
||||
|
||||
InlineListPayload payload = new InlineListPayload(uri, source,
|
||||
intent, true /* isAvailable */, 1);
|
||||
intent, true /* isAvailable */, 1 /* numOptions */, 1 /* default */);
|
||||
|
||||
final Intent retainedIntent = payload.getIntent();
|
||||
assertThat(payload.mSettingKey).isEqualTo(uri);
|
||||
@@ -80,7 +80,7 @@ public class InlineListPayloadTest {
|
||||
public void testInputStandardization_inputDoesntChange() {
|
||||
InlineListPayload payload = new InlineListPayload(DUMMY_SETTING,
|
||||
ResultPayload.SettingsSource.SYSTEM, null /* intent */, true /* isDeviceSupport */,
|
||||
3 /* numOptions */);
|
||||
3 /* numOptions */, 0 /* default */);
|
||||
int input = 2;
|
||||
|
||||
assertThat(payload.standardizeInput(input)).isEqualTo(input);
|
||||
@@ -90,7 +90,7 @@ public class InlineListPayloadTest {
|
||||
public void testSetSystem_negativeValue_throwsError() {
|
||||
InlineListPayload payload = new InlineListPayload(DUMMY_SETTING,
|
||||
ResultPayload.SettingsSource.SYSTEM, null /* intent */, true /* isDeviceSupport */,
|
||||
3 /* numOptions */);
|
||||
3 /* numOptions */, 0 /* default */);
|
||||
|
||||
payload.setValue(mContext, -1);
|
||||
}
|
||||
@@ -100,7 +100,7 @@ public class InlineListPayloadTest {
|
||||
int maxOptions = 4;
|
||||
InlineListPayload payload = new InlineListPayload(DUMMY_SETTING,
|
||||
ResultPayload.SettingsSource.SYSTEM, null /* intent */, true /* isDeviceSupport */,
|
||||
maxOptions /* numOptions */);
|
||||
maxOptions /* numOptions */, 0 /* default */);
|
||||
|
||||
payload.setValue(mContext, maxOptions + 1);
|
||||
}
|
||||
|
@@ -111,7 +111,7 @@ public class InlinePayloadTest {
|
||||
|
||||
public ConcreteInlinePayload(String key, @SettingsSource int source, Intent intent,
|
||||
boolean isDeviceSupported) {
|
||||
super(key, source, intent, isDeviceSupported);
|
||||
super(key, source, intent, isDeviceSupported, 0 /* defaultValue */);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -61,7 +61,8 @@ public class InlineSwitchPayloadTest {
|
||||
final Intent intent = new Intent();
|
||||
intent.putExtra(intentKey, intentVal);
|
||||
|
||||
InlineSwitchPayload payload = new InlineSwitchPayload(uri, source, 1, intent, true);
|
||||
InlineSwitchPayload payload = new InlineSwitchPayload(uri, source, 1, intent, true,
|
||||
1 /* default */);
|
||||
final Intent retainedIntent = payload.getIntent();
|
||||
assertThat(payload.mSettingKey).isEqualTo(uri);
|
||||
assertThat(payload.getType()).isEqualTo(type);
|
||||
@@ -86,6 +87,7 @@ public class InlineSwitchPayloadTest {
|
||||
parcel.writeInt(source);
|
||||
parcel.writeInt(InlineSwitchPayload.TRUE);
|
||||
parcel.writeInt(InlineSwitchPayload.TRUE);
|
||||
parcel.writeInt(InlineSwitchPayload.TRUE);
|
||||
parcel.setDataPosition(0);
|
||||
|
||||
InlineSwitchPayload payload = InlineSwitchPayload.CREATOR.createFromParcel(parcel);
|
||||
@@ -103,7 +105,7 @@ public class InlineSwitchPayloadTest {
|
||||
public void testGetSystem_flippedSetting_returnsFlippedValue() {
|
||||
// Stores 1s as 0s, and vis versa
|
||||
InlineSwitchPayload payload = new InlineSwitchPayload(DUMMY_SETTING, SettingsSource.SYSTEM,
|
||||
FLIPPED_ON, null /* intent */, true);
|
||||
FLIPPED_ON, null /* intent */, true, 1 /* default */);
|
||||
int currentValue = 1;
|
||||
Settings.System.putInt(mContext.getContentResolver(), DUMMY_SETTING, currentValue);
|
||||
|
||||
@@ -116,7 +118,7 @@ public class InlineSwitchPayloadTest {
|
||||
public void testSetSystem_flippedSetting_updatesToFlippedValue() {
|
||||
// Stores 1s as 0s, and vis versa
|
||||
InlineSwitchPayload payload = new InlineSwitchPayload(DUMMY_SETTING, SettingsSource.SYSTEM,
|
||||
FLIPPED_ON, null /* intent */, true);
|
||||
FLIPPED_ON, null /* intent */, true, 1 /* default */);
|
||||
int newValue = 1;
|
||||
ContentResolver resolver = mContext.getContentResolver();
|
||||
Settings.System.putInt(resolver, SCREEN_BRIGHTNESS_MODE, newValue);
|
||||
@@ -130,7 +132,7 @@ public class InlineSwitchPayloadTest {
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testSetSystem_negativeValue_ThrowsError() {
|
||||
InlineSwitchPayload payload = new InlineSwitchPayload(DUMMY_SETTING, SettingsSource.SYSTEM,
|
||||
STANDARD_ON, null /* intent */, true);
|
||||
STANDARD_ON, null /* intent */, true, 1 /* default */);
|
||||
|
||||
payload.setValue(mContext, -1);
|
||||
}
|
||||
@@ -138,7 +140,7 @@ public class InlineSwitchPayloadTest {
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testSetSystem_highValue_ThrowsError() {
|
||||
InlineSwitchPayload payload = new InlineSwitchPayload(DUMMY_SETTING, SettingsSource.SYSTEM,
|
||||
STANDARD_ON, null /* intent */, true);
|
||||
STANDARD_ON, null /* intent */, true, 1 /* default */);
|
||||
|
||||
payload.setValue(mContext, 2);
|
||||
}
|
||||
|
@@ -107,7 +107,8 @@ public class InlineSwitchViewHolderTest {
|
||||
.setSummary(SUMMARY)
|
||||
.setRank(1)
|
||||
.setPayload(new InlineSwitchPayload("" /* uri */, 0 /* mSettingSource */,
|
||||
1 /* onValue */, null /* intent */, true /* isDeviceSupported */))
|
||||
1 /* onValue */, null /* intent */, true /* isDeviceSupported */,
|
||||
1 /* default */))
|
||||
.addBreadcrumbs(new ArrayList<>())
|
||||
.setIcon(mIcon)
|
||||
.setPayload(mPayload)
|
||||
|
Reference in New Issue
Block a user