2011-06-01 17:09:26 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2011 The Android Open Source Project
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package com.android.emailcommon.provider;
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
import android.os.Parcel;
|
|
|
|
import android.test.ProviderTestCase2;
|
|
|
|
import android.test.suitebuilder.annotation.SmallTest;
|
|
|
|
|
Improve EmailContent caching...
* Guarantee that up to 16 Account (with HostAuths), and Policy rows
are always cached. Also, 6 commonly used Mailboxes per Account
(Inbox, Outbox, Drafts, Sent, Trash, and Search)
* Precache these rows when EmailProvider starts up
* Ensure that newly added, precachable rows are cached when created
* Clean up some inefficient/wrong caching code
* Fix a commonly called method in NotificationManager in which we
load a single Mailbox row using selection vs withAppendedId
* Confirm that we don't read from the database in typical use and
heavy message loading
* Add a special URI for finding mailbox by type (using the cache)
* Add special-case code for EmailContent.count(Account.CONTENT_URI)
which is used in a number of places (including on the UI thread)
and whose value is easily determined
* Add a special URI to get the default account id
* Confirm that all unit tests work
The goal here is to be able to load all Account, HostAuth, Policy,
and Mailbox objects (by id) without worrying about disk access.
There will still be a single disk read for uncommon Mailbox reads,
but this should be considered acceptable.
Change-Id: Ibc9aa7acc73185e360b0b6f3053b90a985e97210
TODO: Unit tests
2011-06-19 01:03:11 +00:00
|
|
|
import com.android.email.provider.ContentCache;
|
|
|
|
import com.android.email.provider.EmailProvider;
|
2011-06-01 17:09:26 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Unit tests for the QuickResponse class
|
|
|
|
*/
|
|
|
|
@SmallTest
|
|
|
|
public class QuickResponseTests extends ProviderTestCase2<EmailProvider> {
|
|
|
|
private Context mMockContext;
|
|
|
|
private EmailProvider mProvider;
|
|
|
|
|
|
|
|
public QuickResponseTests() {
|
|
|
|
super(EmailProvider.class, EmailContent.AUTHORITY);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void setUp() throws Exception {
|
|
|
|
super.setUp();
|
|
|
|
mMockContext = getMockContext();
|
|
|
|
mProvider = getProvider();
|
|
|
|
// Invalidate all caches, since we reset the database for each test
|
Improve EmailContent caching...
* Guarantee that up to 16 Account (with HostAuths), and Policy rows
are always cached. Also, 6 commonly used Mailboxes per Account
(Inbox, Outbox, Drafts, Sent, Trash, and Search)
* Precache these rows when EmailProvider starts up
* Ensure that newly added, precachable rows are cached when created
* Clean up some inefficient/wrong caching code
* Fix a commonly called method in NotificationManager in which we
load a single Mailbox row using selection vs withAppendedId
* Confirm that we don't read from the database in typical use and
heavy message loading
* Add a special URI for finding mailbox by type (using the cache)
* Add special-case code for EmailContent.count(Account.CONTENT_URI)
which is used in a number of places (including on the UI thread)
and whose value is easily determined
* Add a special URI to get the default account id
* Confirm that all unit tests work
The goal here is to be able to load all Account, HostAuth, Policy,
and Mailbox objects (by id) without worrying about disk access.
There will still be a single disk read for uncommon Mailbox reads,
but this should be considered acceptable.
Change-Id: Ibc9aa7acc73185e360b0b6f3053b90a985e97210
TODO: Unit tests
2011-06-19 01:03:11 +00:00
|
|
|
ContentCache.invalidateAllCaches();
|
2011-06-01 17:09:26 +00:00
|
|
|
}
|
|
|
|
|
2013-08-14 18:05:19 +00:00
|
|
|
// This class no longer has any content
|
|
|
|
public void brokenTestParcelling() {
|
2011-06-01 17:09:26 +00:00
|
|
|
QuickResponse original = new QuickResponse(7, "quick response text");
|
|
|
|
|
|
|
|
Parcel p = Parcel.obtain();
|
|
|
|
original.writeToParcel(p, 0);
|
|
|
|
|
|
|
|
// Reset.
|
|
|
|
p.setDataPosition(0);
|
|
|
|
|
|
|
|
QuickResponse unparcelled = QuickResponse.CREATOR.createFromParcel(p);
|
|
|
|
assert(original.equals(unparcelled));
|
|
|
|
|
|
|
|
QuickResponse phony = new QuickResponse(17, "quick response text");
|
|
|
|
assert(!(phony.equals(unparcelled)));
|
|
|
|
|
|
|
|
QuickResponse phony2 = new QuickResponse(7, "different text");
|
|
|
|
assert(!(phony2.equals(unparcelled)));
|
|
|
|
|
|
|
|
p.recycle();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|