Loading packages/SettingsProvider/test/AndroidTest.xml +6 −0 Original line number Original line Diff line number Diff line Loading @@ -14,6 +14,12 @@ limitations under the License. limitations under the License. --> --> <configuration description="Run Settings Provider Tests."> <configuration description="Run Settings Provider Tests."> <target_preparer class="com.android.tradefed.targetprep.DeviceSetup"> <option name="set-global-setting" key="verifier_verify_adb_installs" value="0" /> <option name="restore-settings" value="true" /> <option name="force-skip-system-props" value="true" /> </target_preparer> <target_preparer class="com.android.tradefed.targetprep.TestAppInstallSetup"> <target_preparer class="com.android.tradefed.targetprep.TestAppInstallSetup"> <option name="test-file-name" value="SettingsProviderTest.apk" /> <option name="test-file-name" value="SettingsProviderTest.apk" /> </target_preparer> </target_preparer> Loading packages/SettingsProvider/test/src/com/android/providers/settings/GenerationRegistryTest.java +17 −0 Original line number Original line Diff line number Diff line Loading @@ -170,6 +170,23 @@ public class GenerationRegistryTest { checkBundle(b, 1, 2, false); checkBundle(b, 1, 2, false); } } @Test public void testGlobalSettings() throws IOException { final GenerationRegistry generationRegistry = new GenerationRegistry(new Object()); final int globalKey = SettingsState.makeKey(SettingsState.SETTINGS_TYPE_GLOBAL, 0); final String testGlobalSetting = "test_global_setting"; final Bundle b = new Bundle(); generationRegistry.addGenerationData(b, globalKey, testGlobalSetting); checkBundle(b, 0, 1, false); final MemoryIntArray array = getArray(b); final int globalKey2 = SettingsState.makeKey(SettingsState.SETTINGS_TYPE_GLOBAL, 10); b.clear(); generationRegistry.addGenerationData(b, globalKey2, testGlobalSetting); checkBundle(b, 0, 1, false); final MemoryIntArray array2 = getArray(b); // Check that user10 and user0 use the same array to store global settings' generations assertThat(array).isEqualTo(array2); } private void checkBundle(Bundle b, int expectedIndex, int expectedGeneration, boolean isNull) private void checkBundle(Bundle b, int expectedIndex, int expectedGeneration, boolean isNull) throws IOException { throws IOException { Loading Loading
packages/SettingsProvider/test/AndroidTest.xml +6 −0 Original line number Original line Diff line number Diff line Loading @@ -14,6 +14,12 @@ limitations under the License. limitations under the License. --> --> <configuration description="Run Settings Provider Tests."> <configuration description="Run Settings Provider Tests."> <target_preparer class="com.android.tradefed.targetprep.DeviceSetup"> <option name="set-global-setting" key="verifier_verify_adb_installs" value="0" /> <option name="restore-settings" value="true" /> <option name="force-skip-system-props" value="true" /> </target_preparer> <target_preparer class="com.android.tradefed.targetprep.TestAppInstallSetup"> <target_preparer class="com.android.tradefed.targetprep.TestAppInstallSetup"> <option name="test-file-name" value="SettingsProviderTest.apk" /> <option name="test-file-name" value="SettingsProviderTest.apk" /> </target_preparer> </target_preparer> Loading
packages/SettingsProvider/test/src/com/android/providers/settings/GenerationRegistryTest.java +17 −0 Original line number Original line Diff line number Diff line Loading @@ -170,6 +170,23 @@ public class GenerationRegistryTest { checkBundle(b, 1, 2, false); checkBundle(b, 1, 2, false); } } @Test public void testGlobalSettings() throws IOException { final GenerationRegistry generationRegistry = new GenerationRegistry(new Object()); final int globalKey = SettingsState.makeKey(SettingsState.SETTINGS_TYPE_GLOBAL, 0); final String testGlobalSetting = "test_global_setting"; final Bundle b = new Bundle(); generationRegistry.addGenerationData(b, globalKey, testGlobalSetting); checkBundle(b, 0, 1, false); final MemoryIntArray array = getArray(b); final int globalKey2 = SettingsState.makeKey(SettingsState.SETTINGS_TYPE_GLOBAL, 10); b.clear(); generationRegistry.addGenerationData(b, globalKey2, testGlobalSetting); checkBundle(b, 0, 1, false); final MemoryIntArray array2 = getArray(b); // Check that user10 and user0 use the same array to store global settings' generations assertThat(array).isEqualTo(array2); } private void checkBundle(Bundle b, int expectedIndex, int expectedGeneration, boolean isNull) private void checkBundle(Bundle b, int expectedIndex, int expectedGeneration, boolean isNull) throws IOException { throws IOException { Loading