Fix tests broken by I2bf5de4e (Clean-ups for EmailProvider)
My previous CL broke some tests. - make sure to set 0 to unreadCount when adding a new row - when updating messageCount in the tests, directly manipulate the DB. (the provider no longer allows this) Change-Id: Ib569349707007badf4f23600fbca37110c78fa6d
This commit is contained in:
parent
f678a8e67a
commit
5b0c2c7f34
|
@ -1042,7 +1042,12 @@ public class EmailProvider extends ContentProvider {
|
|||
Log.v(TAG, "EmailProvider.insert: uri=" + uri + ", match is " + match);
|
||||
}
|
||||
|
||||
removeAutoColumnsFromContentValues(match, values);
|
||||
// We do NOT allow setting of unreadCount/messageCount via the provider
|
||||
// These columns are maintained via triggers
|
||||
if (match == MAILBOX_ID || match == MAILBOX) {
|
||||
values.put(MailboxColumns.UNREAD_COUNT, 0);
|
||||
values.put(MailboxColumns.MESSAGE_COUNT, 0);
|
||||
}
|
||||
|
||||
Uri resultUri = null;
|
||||
|
||||
|
@ -1261,7 +1266,12 @@ public class EmailProvider extends ContentProvider {
|
|||
Log.v(TAG, "EmailProvider.update: uri=" + uri + ", match is " + match);
|
||||
}
|
||||
|
||||
removeAutoColumnsFromContentValues(match, values);
|
||||
// We do NOT allow setting of unreadCount/messageCount via the provider
|
||||
// These columns are maintained via triggers
|
||||
if (match == MAILBOX_ID || match == MAILBOX) {
|
||||
values.remove(MailboxColumns.UNREAD_COUNT);
|
||||
values.remove(MailboxColumns.MESSAGE_COUNT);
|
||||
}
|
||||
|
||||
String id;
|
||||
try {
|
||||
|
@ -1344,15 +1354,6 @@ public class EmailProvider extends ContentProvider {
|
|||
return result;
|
||||
}
|
||||
|
||||
private static void removeAutoColumnsFromContentValues(int match, ContentValues values) {
|
||||
// We do NOT allow setting of unreadCount/messageCount via the provider
|
||||
// These columns are maintained via triggers
|
||||
if (match == MAILBOX_ID || match == MAILBOX) {
|
||||
values.remove(MailboxColumns.UNREAD_COUNT);
|
||||
values.remove(MailboxColumns.MESSAGE_COUNT);
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see android.content.ContentProvider#applyBatch(android.content.ContentProviderOperation)
|
||||
*/
|
||||
|
|
|
@ -1849,7 +1849,9 @@ public class ProviderTests extends ProviderTestCase2<EmailProvider> {
|
|||
ContentValues values = new ContentValues();
|
||||
values.put(MailboxColumns.MESSAGE_COUNT, -1);
|
||||
|
||||
getProvider().update(Mailbox.CONTENT_URI, values, null, null);
|
||||
// EmailProvider.update() doesn't allow updating messageCount, so directly use the DB.
|
||||
SQLiteDatabase db = getProvider().getDatabase(mMockContext);
|
||||
db.update(Mailbox.TABLE_NAME, values, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue