Simplify InlineSwitchPayloads and generalize get/set method
InlineSwitchPayload now assumes that all switches will be stored as 1 or 0, which simplifies the code. Moves Availability into ResultPayload, so that custom payloads can be created to set/get values which are more complicated than stotring ints (like bluetooth or DnD), and give more expressive reasons when unavailable. Bug: 62022517 Test: make RunSettingsRoboTests Change-Id: I87e6fc041bfd398e7daf6e6e479d502930d36f0f
This commit is contained in:
@@ -86,7 +86,7 @@ public class InlineSwitchViewHolderTest {
|
||||
|
||||
@Test
|
||||
public void testBindViewElements_AllUpdated() {
|
||||
when(mPayload.getSwitchValue(any(Context.class))).thenReturn(true);
|
||||
when(mPayload.getValue(any(Context.class))).thenReturn(1);
|
||||
SearchResult result = getSearchResult();
|
||||
mHolder.onBind(mFragment, result);
|
||||
// Precondition: switch is on.
|
||||
@@ -102,10 +102,12 @@ public class InlineSwitchViewHolderTest {
|
||||
|
||||
private SearchResult getSearchResult() {
|
||||
SearchResult.Builder builder = new SearchResult.Builder();
|
||||
|
||||
builder.setTitle(TITLE)
|
||||
.setSummary(SUMMARY)
|
||||
.setRank(1)
|
||||
.setPayload(new InlineSwitchPayload("", 0, null, null))
|
||||
.setPayload(new InlineSwitchPayload("" /* uri */, 0 /* mSettingSource */,
|
||||
1 /* onValue */, null /* intent */, true /* isDeviceSupported */))
|
||||
.addBreadcrumbs(new ArrayList<>())
|
||||
.setIcon(mIcon)
|
||||
.setPayload(mPayload)
|
||||
|
||||
Reference in New Issue
Block a user