Merge "Fix dispatch in FakeSettings" into sc-v2-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
ae77bd5865
@@ -123,11 +123,11 @@ public class FakeSettings implements SecureSettings, GlobalSettings, SystemSetti
|
|||||||
|
|
||||||
Uri uri = getUriFor(name);
|
Uri uri = getUriFor(name);
|
||||||
for (ContentObserver observer : mContentObservers.getOrDefault(key, new ArrayList<>())) {
|
for (ContentObserver observer : mContentObservers.getOrDefault(key, new ArrayList<>())) {
|
||||||
observer.dispatchChange(false, List.of(uri), userHandle);
|
observer.dispatchChange(false, List.of(uri), 0, userHandle);
|
||||||
}
|
}
|
||||||
for (ContentObserver observer :
|
for (ContentObserver observer :
|
||||||
mContentObserversAllUsers.getOrDefault(uri.toString(), new ArrayList<>())) {
|
mContentObserversAllUsers.getOrDefault(uri.toString(), new ArrayList<>())) {
|
||||||
observer.dispatchChange(false, List.of(uri), userHandle);
|
observer.dispatchChange(false, List.of(uri), 0, userHandle);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import static com.google.common.truth.Truth.assertThat;
|
|||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.ArgumentMatchers.anyBoolean;
|
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||||
import static org.mockito.ArgumentMatchers.anyInt;
|
import static org.mockito.ArgumentMatchers.anyInt;
|
||||||
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
import static org.mockito.Mockito.never;
|
import static org.mockito.Mockito.never;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
|
|
||||||
@@ -86,7 +87,8 @@ public class FakeSettingsTest extends SysuiTestCase {
|
|||||||
|
|
||||||
mFakeSettings.putString("cat", "hat");
|
mFakeSettings.putString("cat", "hat");
|
||||||
|
|
||||||
verify(mContentObserver).dispatchChange(anyBoolean(), any(Collection.class), anyInt());
|
verify(mContentObserver).dispatchChange(anyBoolean(), any(Collection.class), anyInt(),
|
||||||
|
anyInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -96,7 +98,8 @@ public class FakeSettingsTest extends SysuiTestCase {
|
|||||||
|
|
||||||
mFakeSettings.putString("cat", "hat");
|
mFakeSettings.putString("cat", "hat");
|
||||||
|
|
||||||
verify(mContentObserver).dispatchChange(anyBoolean(), any(Collection.class), anyInt());
|
verify(mContentObserver).dispatchChange(anyBoolean(), any(Collection.class), anyInt(),
|
||||||
|
anyInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -119,6 +122,18 @@ public class FakeSettingsTest extends SysuiTestCase {
|
|||||||
mFakeSettings.putString("cat", "hat");
|
mFakeSettings.putString("cat", "hat");
|
||||||
|
|
||||||
verify(mContentObserver, never()).dispatchChange(
|
verify(mContentObserver, never()).dispatchChange(
|
||||||
anyBoolean(), any(Collection.class), anyInt());
|
anyBoolean(), any(Collection.class), anyInt(), anyInt());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testContentObserverDispatchCorrectUser() {
|
||||||
|
int user = 10;
|
||||||
|
mFakeSettings.registerContentObserverForUser(
|
||||||
|
mFakeSettings.getUriFor("cat"), false, mContentObserver, UserHandle.USER_ALL
|
||||||
|
);
|
||||||
|
|
||||||
|
mFakeSettings.putStringForUser("cat", "hat", user);
|
||||||
|
verify(mContentObserver).dispatchChange(anyBoolean(), any(Collection.class), anyInt(),
|
||||||
|
eq(user));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user