summaryrefslogtreecommitdiffstats
path: root/core/tests
diff options
context:
space:
mode:
authorMaggie Benthall <mbenthall@google.com>2013-02-04 13:28:19 -0500
committerMaggie Benthall <mbenthall@google.com>2013-02-06 18:53:47 -0500
commitd2726582f135383e56661bc41d750966642dab45 (patch)
treec3a4b288963fc5acc95f7f6f1c805dc566e39076 /core/tests
parent484f3bdcd663d4ddc9521e788c45338b34a1691d (diff)
downloadframeworks_base-d2726582f135383e56661bc41d750966642dab45.zip
frameworks_base-d2726582f135383e56661bc41d750966642dab45.tar.gz
frameworks_base-d2726582f135383e56661bc41d750966642dab45.tar.bz2
Fix for SettingsProvider to query for correct user.
insertForUser takes a specified user and attempts to adjust that user's settings, first looking at their existing settings to determine the difference. However it was querying the settings for the calling user, rather than for the user whose settings were being changed. Also add a test that exercises the fix. Change-Id: I6ed6fd79154ac1b6e6ab880769ac9081dfff6b80
Diffstat (limited to 'core/tests')
-rw-r--r--core/tests/coretests/src/android/provider/SettingsProviderTest.java36
1 files changed, 36 insertions, 0 deletions
diff --git a/core/tests/coretests/src/android/provider/SettingsProviderTest.java b/core/tests/coretests/src/android/provider/SettingsProviderTest.java
index 6edd2dc..131651a 100644
--- a/core/tests/coretests/src/android/provider/SettingsProviderTest.java
+++ b/core/tests/coretests/src/android/provider/SettingsProviderTest.java
@@ -132,6 +132,42 @@ public class SettingsProviderTest extends AndroidTestCase {
}
@MediumTest
+ public void testSettingsChangeForOtherUser() {
+ UserManager um = (UserManager) getContext().getSystemService(Context.USER_SERVICE);
+ ContentResolver r = getContext().getContentResolver();
+
+ // Make sure there's an owner
+ assertTrue(findUser(um, UserHandle.USER_OWNER));
+
+ // create a new user to use for testing
+ UserInfo otherUser = um.createUser("TestUser1", UserInfo.FLAG_GUEST);
+ assertTrue(otherUser != null);
+ try {
+ assertNotSame("Current calling user id should not be the new guest user",
+ otherUser.id, UserHandle.getCallingUserId());
+
+ Settings.Secure.putString(r, Settings.Secure.LOCATION_PROVIDERS_ALLOWED, "gps");
+ Settings.Secure.putStringForUser(r,
+ Settings.Secure.LOCATION_PROVIDERS_ALLOWED, "network", otherUser.id);
+
+ assertEquals("gps",
+ Settings.Secure.getString(r, Settings.Secure.LOCATION_PROVIDERS_ALLOWED));
+ assertEquals("network", Settings.Secure.getStringForUser(
+ r, Settings.Secure.LOCATION_PROVIDERS_ALLOWED, otherUser.id));
+
+ assertNotSame("Current calling user id should not be the new guest user",
+ otherUser.id, UserHandle.getCallingUserId());
+ Settings.Secure.setLocationProviderEnabledForUser(r, "network", false, otherUser.id);
+ assertEquals("", Settings.Secure.getStringForUser(
+ r, Settings.Secure.LOCATION_PROVIDERS_ALLOWED, otherUser.id));
+
+ } finally {
+ // Tidy up
+ um.removeUser(otherUser.id);
+ }
+ }
+
+ @MediumTest
public void testRowNumberContentUri() {
ContentResolver r = getContext().getContentResolver();