summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMakoto Onuki <omakoto@google.com>2012-03-23 10:53:44 -0700
committerMakoto Onuki <omakoto@google.com>2012-03-23 11:14:18 -0700
commit084fe28445cf74e3fa93522f8f8e5da6e065b8c3 (patch)
treee78ffd720821f6a94625d5f6afbc9953bea8bf94 /tests
parentd3256d7ba4ee8376567f91c1c2dec444ad13d542 (diff)
downloadpackages_providers_ContactsProvider-084fe28445cf74e3fa93522f8f8e5da6e065b8c3.zip
packages_providers_ContactsProvider-084fe28445cf74e3fa93522f8f8e5da6e065b8c3.tar.gz
packages_providers_ContactsProvider-084fe28445cf74e3fa93522f8f8e5da6e065b8c3.tar.bz2
Make informational queries respect requested projection
Fixed: - DisplayPhoto.CONTENT_MAX_DIMENSIONS_URI - StreamItems.CONTENT_LIMIT_URI Also now ProviderStatus now throws when a non-existent column is requested. Change-Id: I03c82c31fe78a30d4929335dfb8efc3bff3bc76b
Diffstat (limited to 'tests')
-rw-r--r--tests/src/com/android/providers/contacts/ContactsProvider2Test.java47
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/src/com/android/providers/contacts/ContactsProvider2Test.java b/tests/src/com/android/providers/contacts/ContactsProvider2Test.java
index bef077c..c7f7dcb 100644
--- a/tests/src/com/android/providers/contacts/ContactsProvider2Test.java
+++ b/tests/src/com/android/providers/contacts/ContactsProvider2Test.java
@@ -6393,6 +6393,53 @@ public class ContactsProvider2Test extends BaseContactsProvider2Test {
cursor.close();
}
+ public void testBuildSingleRowResult() {
+ checkBuildSingleRowResult(
+ new String[] {"b"},
+ new String[] {"a", "b"},
+ new Integer[] {1, 2},
+ new Integer[] {2}
+ );
+
+ checkBuildSingleRowResult(
+ new String[] {"b", "a", "b"},
+ new String[] {"a", "b"},
+ new Integer[] {1, 2},
+ new Integer[] {2, 1, 2}
+ );
+
+ checkBuildSingleRowResult(
+ null, // all columns
+ new String[] {"a", "b"},
+ new Integer[] {1, 2},
+ new Integer[] {1, 2}
+ );
+
+ try {
+ // Access non-existent column
+ ContactsProvider2.buildSingleRowResult(new String[] {"a"}, new String[] {"b"},
+ new Object[] {1});
+ fail();
+ } catch (IllegalArgumentException expected) {
+ }
+ }
+
+ private void checkBuildSingleRowResult(String[] projection, String[] availableColumns,
+ Object[] data, Integer[] expectedValues) {
+ final Cursor c = ContactsProvider2.buildSingleRowResult(projection, availableColumns, data);
+ try {
+ assertTrue(c.moveToFirst());
+ assertEquals(1, c.getCount());
+ assertEquals(expectedValues.length, c.getColumnCount());
+
+ for (int i = 0; i < expectedValues.length; i++) {
+ assertEquals("column " + i, expectedValues[i], (Integer) c.getInt(i));
+ }
+ } finally {
+ c.close();
+ }
+ }
+
private Cursor queryGroupMemberships(Account account) {
Cursor c = mResolver.query(maybeAddAccountQueryParameters(Data.CONTENT_URI, account),
new String[]{GroupMembership.GROUP_ROW_ID, GroupMembership.RAW_CONTACT_ID},