diff options
author | Roman Birg <roman@cyngn.com> | 2015-12-18 12:01:07 -0800 |
---|---|---|
committer | Roman Birg <roman@cyngn.com> | 2015-12-21 10:30:22 -0800 |
commit | 20bfdd7e3fbaa25f0f8da2d4ff9b9c3549460f79 (patch) | |
tree | 6c3a41b30742b26a7a4b2e527d3e32a029aa7224 /packages/CMSettingsProvider | |
parent | cb4a990216b9e0960a6c927651eba8649f8d9619 (diff) | |
download | vendor_cmsdk-20bfdd7e3fbaa25f0f8da2d4ff9b9c3549460f79.zip vendor_cmsdk-20bfdd7e3fbaa25f0f8da2d4ff9b9c3549460f79.tar.gz vendor_cmsdk-20bfdd7e3fbaa25f0f8da2d4ff9b9c3549460f79.tar.bz2 |
cmsdk: add keys which to intercept from SettingsProvider
Change-Id: Id5d86cc97eb2411322af5686e6d79fa5fb190891
Signed-off-by: Roman Birg <roman@cyngn.com>
Diffstat (limited to 'packages/CMSettingsProvider')
-rw-r--r-- | packages/CMSettingsProvider/tests/src/org/cyanogenmod/cmsettings/tests/CMSettingsProviderTest.java | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/packages/CMSettingsProvider/tests/src/org/cyanogenmod/cmsettings/tests/CMSettingsProviderTest.java b/packages/CMSettingsProvider/tests/src/org/cyanogenmod/cmsettings/tests/CMSettingsProviderTest.java index 658a3f6..8c1341d 100644 --- a/packages/CMSettingsProvider/tests/src/org/cyanogenmod/cmsettings/tests/CMSettingsProviderTest.java +++ b/packages/CMSettingsProvider/tests/src/org/cyanogenmod/cmsettings/tests/CMSettingsProviderTest.java @@ -30,6 +30,7 @@ import android.os.UserManager; import android.provider.Settings; import android.test.AndroidTestCase; import android.test.suitebuilder.annotation.MediumTest; +import android.test.suitebuilder.annotation.SmallTest; import android.text.TextUtils; import cyanogenmod.providers.CMSettings; import org.cyanogenmod.cmsettings.CMSettingsProvider; @@ -79,6 +80,45 @@ import java.util.Map; testMigrateSettingsForUser(mGuest.id); } + /** + * make sure that queries to SettingsProvider are forwarded to CMSettingsProvider as needed + * See {@link cyanogenmod.providers.CMSettings.System#shouldInterceptSystemProvider(String)} + * + * Currently this test only checks that + * {@link cyanogenmod.providers.CMSettings.System#SYSTEM_PROFILES_ENABLED} is expected to + * be forwarded, and is forwarded. + */ + @SmallTest + public void testSettingsProviderKeyForwarding() { + String forwardedKey = CMSettings.System.SYSTEM_PROFILES_ENABLED; + + // make sure the key should be forwarded + assertTrue(CMSettings.System.shouldInterceptSystemProvider(forwardedKey)); + + // put value 1 into Settings provider: + // let's try to disable the profiles via the Settings provider + Settings.System.putStringForUser(mContentResolver, + forwardedKey, "0", UserHandle.USER_CURRENT); + + // assert this is what we just put in there + assertEquals("0", Settings.System.getStringForUser(getContext().getContentResolver(), + forwardedKey, UserHandle.USER_CURRENT)); + + // put value 2 into CMSettings provider + CMSettings.System.putStringForUser(mContentResolver, + forwardedKey, "1", UserHandle.USER_CURRENT); + + assertEquals("1", CMSettings.System.getStringForUser(getContext().getContentResolver(), + forwardedKey, UserHandle.USER_CURRENT)); + + // assert reading from both returns value 2 + final String cmProviderValue = CMSettings.System.getStringForUser( + getContext().getContentResolver(), forwardedKey, UserHandle.USER_CURRENT); + final String settingsProviderValue = Settings.System.getStringForUser( + getContext().getContentResolver(), forwardedKey, UserHandle.USER_CURRENT); + assertEquals(cmProviderValue, settingsProviderValue); + } + private void testMigrateSettingsForUser(int userId) { // Setup values in Settings /*final String expectedPullDownValue = "testQuickPullDownValue"; |