diff options
author | Matthew Williams <mjwilliams@google.com> | 2015-10-16 12:01:31 -0700 |
---|---|---|
committer | Matthew Williams <mjwilliams@google.com> | 2015-10-20 18:55:30 +0000 |
commit | 7d7a2254bc41d2dfc34fbb8693cb0dad2ccd528a (patch) | |
tree | ddba8db034a618312524d6cf1252d766990d96c8 /services/tests | |
parent | cfea184d6c0268b92ed55276d2b686962c8ee531 (diff) | |
download | frameworks_base-7d7a2254bc41d2dfc34fbb8693cb0dad2ccd528a.zip frameworks_base-7d7a2254bc41d2dfc34fbb8693cb0dad2ccd528a.tar.gz frameworks_base-7d7a2254bc41d2dfc34fbb8693cb0dad2ccd528a.tar.bz2 |
DO NOT MERGE Sync extras bundle comparison can throw NPE
BUG: 23591205
Change-Id: Ic6404c0befe70c34b078e0eae6a627826173d82c
(cherry picked from commit 9ad2c8403354a985258c098681067e74b9e2f638)
Diffstat (limited to 'services/tests')
-rw-r--r-- | services/tests/servicestests/src/com/android/server/content/SyncManagerTest.java | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/services/tests/servicestests/src/com/android/server/content/SyncManagerTest.java b/services/tests/servicestests/src/com/android/server/content/SyncManagerTest.java new file mode 100644 index 0000000..be6861c --- /dev/null +++ b/services/tests/servicestests/src/com/android/server/content/SyncManagerTest.java @@ -0,0 +1,64 @@ +package com.android.server.content; + +import android.os.Bundle; + +import junit.framework.TestCase; + +public class SyncManagerTest extends TestCase { + + final String KEY_1 = "key_1"; + final String KEY_2 = "key_2"; + + public void testSyncExtrasEquals_WithNull() throws Exception { + Bundle b1 = new Bundle(); + Bundle b2 = new Bundle(); + + b1.putString(KEY_1, null); + b2.putString(KEY_1, null); + + assertTrue("Null extra not properly compared between bundles.", + SyncManager.syncExtrasEquals(b1, b2, false /* don't care about system extras */)); + } + + public void testSyncExtrasEqualsBigger_WithNull() throws Exception { + Bundle b1 = new Bundle(); + Bundle b2 = new Bundle(); + + b1.putString(KEY_1, null); + b2.putString(KEY_1, null); + + b1.putString(KEY_2, "bla"); + b2.putString(KEY_2, "bla"); + + assertTrue("Extras not properly compared between bundles.", + SyncManager.syncExtrasEquals(b1, b2, false /* don't care about system extras */)); + } + + public void testSyncExtrasEqualsFails_differentValues() throws Exception { + Bundle b1 = new Bundle(); + Bundle b2 = new Bundle(); + + b1.putString(KEY_1, null); + b2.putString(KEY_1, null); + + b1.putString(KEY_2, "bla"); + b2.putString(KEY_2, "ble"); // different key + + assertFalse("Extras considered equal when they are different.", + SyncManager.syncExtrasEquals(b1, b2, false /* don't care about system extras */)); + } + + public void testSyncExtrasEqualsFails_differentNulls() throws Exception { + Bundle b1 = new Bundle(); + Bundle b2 = new Bundle(); + + b1.putString(KEY_1, null); + b2.putString(KEY_1, "bla"); // different key + + b1.putString(KEY_2, "ble"); + b2.putString(KEY_2, "ble"); + + assertFalse("Extras considered equal when they are different.", + SyncManager.syncExtrasEquals(b1, b2, false /* don't care about system extras */)); + } +} |