Merge branch 'readonly-p4-master'
This commit is contained in:
commit
d4b2a71206
@ -60,4 +60,29 @@ public enum Flag {
|
||||
* This does not include attachments, which are never downloaded fully.
|
||||
*/
|
||||
X_DOWNLOADED_PARTIAL,
|
||||
|
||||
/**
|
||||
* General purpose flag that can be used by any remote store. The flag will be
|
||||
* saved and restored by the LocalStore.
|
||||
*/
|
||||
X_STORE_1,
|
||||
|
||||
/**
|
||||
* General purpose flag that can be used by any remote store. The flag will be
|
||||
* saved and restored by the LocalStore.
|
||||
*/
|
||||
X_STORE_2,
|
||||
|
||||
/**
|
||||
* General purpose flag that can be used by any remote store. The flag will be
|
||||
* saved and restored by the LocalStore.
|
||||
*/
|
||||
X_STORE_3,
|
||||
|
||||
/**
|
||||
* General purpose flag that can be used by any remote store. The flag will be
|
||||
* saved and restored by the LocalStore.
|
||||
*/
|
||||
X_STORE_4,
|
||||
|
||||
}
|
||||
|
@ -16,9 +16,8 @@
|
||||
|
||||
package com.android.email.mail.internet;
|
||||
|
||||
import com.android.email.mail.Flag;
|
||||
import com.android.email.mail.MessagingException;
|
||||
import com.android.email.mail.internet.MimeHeader;
|
||||
import com.android.email.mail.internet.MimeMessage;
|
||||
|
||||
import android.test.suitebuilder.annotation.SmallTest;
|
||||
|
||||
@ -211,5 +210,39 @@ public class MimeMessageTest extends TestCase {
|
||||
trimmed.startsWith("=?") && trimmed.endsWith("?="));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test setting & getting store-specific flags
|
||||
*/
|
||||
public void testStoreFlags() throws MessagingException {
|
||||
MimeMessage message = new MimeMessage();
|
||||
|
||||
// Message should create with no flags
|
||||
Flag[] flags = message.getFlags();
|
||||
assertEquals(0, flags.length);
|
||||
|
||||
// Set a store flag
|
||||
message.setFlag(Flag.X_STORE_1, true);
|
||||
assertTrue(message.isSet(Flag.X_STORE_1));
|
||||
assertFalse(message.isSet(Flag.X_STORE_2));
|
||||
assertFalse(message.isSet(Flag.X_STORE_3));
|
||||
assertFalse(message.isSet(Flag.X_STORE_4));
|
||||
|
||||
// Set another
|
||||
message.setFlag(Flag.X_STORE_2, true);
|
||||
assertTrue(message.isSet(Flag.X_STORE_1));
|
||||
assertTrue(message.isSet(Flag.X_STORE_2));
|
||||
assertFalse(message.isSet(Flag.X_STORE_3));
|
||||
assertFalse(message.isSet(Flag.X_STORE_4));
|
||||
|
||||
// Set some and clear some
|
||||
message.setFlag(Flag.X_STORE_1, false);
|
||||
message.setFlag(Flag.X_STORE_3, true);
|
||||
assertFalse(message.isSet(Flag.X_STORE_1));
|
||||
assertTrue(message.isSet(Flag.X_STORE_2));
|
||||
assertTrue(message.isSet(Flag.X_STORE_3));
|
||||
assertFalse(message.isSet(Flag.X_STORE_4));
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -18,6 +18,7 @@ package com.android.email.mail.store;
|
||||
|
||||
import com.android.email.Email;
|
||||
import com.android.email.mail.Address;
|
||||
import com.android.email.mail.Flag;
|
||||
import com.android.email.mail.Folder;
|
||||
import com.android.email.mail.Message;
|
||||
import com.android.email.mail.MessagingException;
|
||||
@ -251,6 +252,48 @@ public class LocalStoreUnitTests extends AndroidTestCase {
|
||||
assertEquals("value-2-2b", callbacks2.getPersistentString("key2", null)); // changed
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that messages are being stored with store flags properly persisted.
|
||||
*
|
||||
* This variant tests appendMessages() and updateMessages() and getMessage()
|
||||
*/
|
||||
public void testStoreFlags() throws MessagingException {
|
||||
final MimeMessage message = buildTestMessage(RECIPIENT_TO, SENDER, SUBJECT, BODY);
|
||||
message.setMessageId(MESSAGE_ID);
|
||||
message.setFlag(Flag.X_STORE_3, true);
|
||||
message.setFlag(Flag.X_STORE_4, true);
|
||||
|
||||
mFolder.open(OpenMode.READ_WRITE, null);
|
||||
mFolder.appendMessages(new Message[]{ message });
|
||||
String localUid = message.getUid();
|
||||
|
||||
// Now try to read it back from the database using getMessage()
|
||||
|
||||
MimeMessage retrieved = (MimeMessage) mFolder.getMessage(localUid);
|
||||
assertEquals(MESSAGE_ID, retrieved.getMessageId());
|
||||
assertFalse(message.isSet(Flag.X_STORE_1));
|
||||
assertFalse(message.isSet(Flag.X_STORE_2));
|
||||
assertTrue(message.isSet(Flag.X_STORE_3));
|
||||
assertTrue(message.isSet(Flag.X_STORE_4));
|
||||
|
||||
// Now try to update it using updateMessages()
|
||||
|
||||
retrieved.setFlag(Flag.X_STORE_2, true);
|
||||
retrieved.setFlag(Flag.X_STORE_4, false);
|
||||
mFolder.updateMessage((LocalStore.LocalMessage)retrieved);
|
||||
|
||||
// And read back once more to confirm the change (using getMessages() to confirm "just one")
|
||||
Message[] retrievedArray = mFolder.getMessages(null);
|
||||
assertEquals(1, retrievedArray.length);
|
||||
MimeMessage retrievedEntry = (MimeMessage) retrievedArray[0];
|
||||
assertEquals(MESSAGE_ID, retrieved.getMessageId());
|
||||
|
||||
assertFalse(retrievedEntry.isSet(Flag.X_STORE_1));
|
||||
assertTrue(retrievedEntry.isSet(Flag.X_STORE_2));
|
||||
assertTrue(retrievedEntry.isSet(Flag.X_STORE_3));
|
||||
assertFalse(retrievedEntry.isSet(Flag.X_STORE_4));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test visible limits support
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user