PageRenderTime 32ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/tests/src/com/android/email/ControllerProviderOpsTests.java

https://bitbucket.org/camcory/android_packages_apps_email
Java | 532 lines | 348 code | 70 blank | 114 comment | 6 complexity | 9710ba7c3e754acbe34af5cf1f59f593 MD5 | raw file
  1. /*
  2. * Copyright (C) 2009 The Android Open Source Project
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package com.android.email;
  17. import android.content.Context;
  18. import android.net.Uri;
  19. import android.test.ProviderTestCase2;
  20. import com.android.email.provider.ContentCache;
  21. import com.android.email.provider.EmailProvider;
  22. import com.android.email.provider.ProviderTestUtils;
  23. import com.android.emailcommon.provider.Account;
  24. import com.android.emailcommon.provider.EmailContent;
  25. import com.android.emailcommon.provider.EmailContent.Body;
  26. import com.android.emailcommon.provider.EmailContent.Message;
  27. import com.android.emailcommon.provider.HostAuth;
  28. import com.android.emailcommon.provider.Mailbox;
  29. import java.util.Locale;
  30. import java.util.concurrent.ExecutionException;
  31. /**
  32. * Tests of the Controller class that depend on the underlying provider.
  33. *
  34. * NOTE: It would probably make sense to rewrite this using a MockProvider, instead of the
  35. * ProviderTestCase (which is a real provider running on a temp database). This would be more of
  36. * a true "unit test".
  37. *
  38. * You can run this entire test case with:
  39. * runtest -c com.android.email.ControllerProviderOpsTests email
  40. */
  41. public class ControllerProviderOpsTests extends ProviderTestCase2<EmailProvider> {
  42. private Context mProviderContext;
  43. private Context mContext;
  44. private TestController mTestController;
  45. public ControllerProviderOpsTests() {
  46. super(EmailProvider.class, EmailContent.AUTHORITY);
  47. }
  48. @Override
  49. public void setUp() throws Exception {
  50. super.setUp();
  51. mProviderContext = getMockContext();
  52. mContext = getContext();
  53. mTestController = new TestController(mProviderContext, mContext);
  54. // Invalidate all caches, since we reset the database for each test
  55. ContentCache.invalidateAllCaches();
  56. }
  57. @Override
  58. public void tearDown() throws Exception {
  59. super.tearDown();
  60. mTestController.cleanupForTest();
  61. }
  62. /**
  63. * Lightweight subclass of the Controller class allows injection of mock context
  64. */
  65. public static class TestController extends Controller {
  66. protected TestController(Context providerContext, Context systemContext) {
  67. super(systemContext);
  68. setProviderContext(providerContext);
  69. }
  70. }
  71. /**
  72. * These are strings that should not change per locale.
  73. */
  74. public void testGetMailboxServerName() {
  75. assertEquals("", Controller.getMailboxServerName(mContext, -1));
  76. assertEquals("Inbox", Controller.getMailboxServerName(mContext, Mailbox.TYPE_INBOX));
  77. assertEquals("Outbox", Controller.getMailboxServerName(mContext, Mailbox.TYPE_OUTBOX));
  78. assertEquals("Trash", Controller.getMailboxServerName(mContext, Mailbox.TYPE_TRASH));
  79. assertEquals("Sent", Controller.getMailboxServerName(mContext, Mailbox.TYPE_SENT));
  80. assertEquals("Junk", Controller.getMailboxServerName(mContext, Mailbox.TYPE_JUNK));
  81. // Now try again with translation
  82. Locale savedLocale = Locale.getDefault();
  83. Locale.setDefault(Locale.FRANCE);
  84. assertEquals("Inbox", Controller.getMailboxServerName(mContext, Mailbox.TYPE_INBOX));
  85. assertEquals("Outbox", Controller.getMailboxServerName(mContext, Mailbox.TYPE_OUTBOX));
  86. assertEquals("Trash", Controller.getMailboxServerName(mContext, Mailbox.TYPE_TRASH));
  87. assertEquals("Sent", Controller.getMailboxServerName(mContext, Mailbox.TYPE_SENT));
  88. assertEquals("Junk", Controller.getMailboxServerName(mContext, Mailbox.TYPE_JUNK));
  89. Locale.setDefault(savedLocale);
  90. }
  91. /**
  92. * Test of Controller.createMailbox().
  93. * Sunny day test only - creates a mailbox that does not exist.
  94. * Does not test duplication, bad accountID, or any other bad input.
  95. */
  96. public void testCreateMailbox() {
  97. // safety check that system mailboxes don't exist ...
  98. assertEquals(Mailbox.NO_MAILBOX,
  99. Mailbox.findMailboxOfType(mProviderContext, 1L, Mailbox.TYPE_DRAFTS));
  100. assertEquals(Mailbox.NO_MAILBOX,
  101. Mailbox.findMailboxOfType(mProviderContext, 1L, Mailbox.TYPE_SENT));
  102. long testMailboxId;
  103. Mailbox testMailbox;
  104. // Test creating "drafts" mailbox
  105. mTestController.createMailbox(1L, Mailbox.TYPE_DRAFTS);
  106. testMailboxId = Mailbox.findMailboxOfType(mProviderContext, 1L, Mailbox.TYPE_DRAFTS);
  107. assertTrue(testMailboxId != Mailbox.NO_MAILBOX);
  108. testMailbox = Mailbox.restoreMailboxWithId(mProviderContext, testMailboxId);
  109. assertNotNull(testMailbox);
  110. assertEquals(8, testMailbox.mFlags); // Flags should be "holds mail"
  111. assertEquals(-1L, testMailbox.mParentKey); // Parent is off the top-level
  112. // Test creating "sent" mailbox; same as drafts
  113. mTestController.createMailbox(1L, Mailbox.TYPE_SENT);
  114. testMailboxId = Mailbox.findMailboxOfType(mProviderContext, 1L, Mailbox.TYPE_SENT);
  115. assertTrue(testMailboxId != Mailbox.NO_MAILBOX);
  116. testMailbox = Mailbox.restoreMailboxWithId(mProviderContext, testMailboxId);
  117. assertNotNull(testMailbox);
  118. assertEquals(8, testMailbox.mFlags); // Flags should be "holds mail"
  119. assertEquals(-1L, testMailbox.mParentKey); // Parent is off the top-level
  120. }
  121. /**
  122. * Test of Controller.findOrCreateMailboxOfType().
  123. * Checks:
  124. * - finds correctly the ID of existing mailbox
  125. * - creates non-existing mailbox
  126. * - creates only once a new mailbox
  127. * - when accountId or mailboxType are -1, returns NO_MAILBOX
  128. */
  129. public void testFindOrCreateMailboxOfType() {
  130. Account account = ProviderTestUtils.setupAccount("mailboxid", true, mProviderContext);
  131. long accountId = account.mId;
  132. Mailbox box = ProviderTestUtils.setupMailbox("box", accountId, false, mProviderContext);
  133. final int boxType = Mailbox.TYPE_TRASH;
  134. box.mType = boxType;
  135. box.save(mProviderContext);
  136. long boxId = box.mId;
  137. long testBoxId = mTestController.findOrCreateMailboxOfType(accountId, boxType);
  138. // check it found the right mailbox id
  139. assertEquals(boxId, testBoxId);
  140. long boxId2 = mTestController.findOrCreateMailboxOfType(accountId, Mailbox.TYPE_DRAFTS);
  141. assertTrue("mailbox created", boxId2 != Mailbox.NO_MAILBOX);
  142. assertTrue("with different id", testBoxId != boxId2);
  143. // check it doesn't create twice when existing
  144. long boxId3 = mTestController.findOrCreateMailboxOfType(accountId, Mailbox.TYPE_DRAFTS);
  145. assertEquals("don't create if exists", boxId3, boxId2);
  146. // check invalid aruments
  147. assertEquals(Mailbox.NO_MAILBOX,
  148. mTestController.findOrCreateMailboxOfType(-1, Mailbox.TYPE_DRAFTS));
  149. assertEquals(Mailbox.NO_MAILBOX, mTestController.findOrCreateMailboxOfType(accountId, -1));
  150. }
  151. /**
  152. * Test the "move message" function.
  153. */
  154. public void testMoveMessage() throws InterruptedException, ExecutionException {
  155. Account account1 = ProviderTestUtils.setupAccount("message-move", true, mProviderContext);
  156. long account1Id = account1.mId;
  157. Mailbox box1 = ProviderTestUtils.setupMailbox("box1", account1Id, true, mProviderContext);
  158. long box1Id = box1.mId;
  159. Mailbox box2 = ProviderTestUtils.setupMailbox("box2", account1Id, true, mProviderContext);
  160. long box2Id = box2.mId;
  161. Mailbox boxDest = ProviderTestUtils.setupMailbox("d", account1Id, true, mProviderContext);
  162. long boxDestId = boxDest.mId;
  163. Message message1 = ProviderTestUtils.setupMessage("message1", account1Id, box1Id, false,
  164. true, mProviderContext);
  165. Message message2 = ProviderTestUtils.setupMessage("message2", account1Id, box2Id, false,
  166. true, mProviderContext);
  167. long message1Id = message1.mId;
  168. long message2Id = message2.mId;
  169. // Because moveMessage runs asynchronously, call get() to force it to complete
  170. mTestController.moveMessages(new long[] { message1Id, message2Id }, boxDestId).get();
  171. // now read back a fresh copy and confirm it's in the trash
  172. assertEquals(boxDestId, EmailContent.Message.restoreMessageWithId(mProviderContext,
  173. message1Id).mMailboxKey);
  174. assertEquals(boxDestId, EmailContent.Message.restoreMessageWithId(mProviderContext,
  175. message2Id).mMailboxKey);
  176. }
  177. /**
  178. * Test the "delete message" function. Sunny day:
  179. * - message/mailbox/account all exist
  180. * - trash mailbox exists
  181. */
  182. public void testDeleteMessage() {
  183. Account account1 = ProviderTestUtils.setupAccount("message-delete", true, mProviderContext);
  184. long account1Id = account1.mId;
  185. Mailbox box = ProviderTestUtils.setupMailbox("box1", account1Id, true, mProviderContext);
  186. long boxId = box.mId;
  187. Mailbox trashBox = ProviderTestUtils.setupMailbox("box2", account1Id, false,
  188. mProviderContext);
  189. trashBox.mType = Mailbox.TYPE_TRASH;
  190. trashBox.save(mProviderContext);
  191. long trashBoxId = trashBox.mId;
  192. Mailbox draftBox = ProviderTestUtils.setupMailbox("box3", account1Id, false,
  193. mProviderContext);
  194. draftBox.mType = Mailbox.TYPE_DRAFTS;
  195. draftBox.save(mProviderContext);
  196. long draftBoxId = draftBox.mId;
  197. {
  198. // Case 1: Message in a regular mailbox, account known.
  199. Message message = ProviderTestUtils.setupMessage("message1", account1Id, boxId, false,
  200. true, mProviderContext);
  201. long messageId = message.mId;
  202. mTestController.deleteMessageSync(messageId);
  203. // now read back a fresh copy and confirm it's in the trash
  204. Message restored = EmailContent.Message.restoreMessageWithId(mProviderContext,
  205. messageId);
  206. assertEquals(trashBoxId, restored.mMailboxKey);
  207. }
  208. {
  209. // Case 2: Already in trash
  210. Message message = ProviderTestUtils.setupMessage("message3", account1Id, trashBoxId,
  211. false, true, mProviderContext);
  212. long messageId = message.mId;
  213. mTestController.deleteMessageSync(messageId);
  214. // Message should be deleted.
  215. assertNull(EmailContent.Message.restoreMessageWithId(mProviderContext, messageId));
  216. }
  217. {
  218. // Case 3: Draft
  219. Message message = ProviderTestUtils.setupMessage("message3", account1Id, draftBoxId,
  220. false, true, mProviderContext);
  221. long messageId = message.mId;
  222. mTestController.deleteMessageSync(messageId);
  223. // Message should be deleted.
  224. assertNull(EmailContent.Message.restoreMessageWithId(mProviderContext, messageId));
  225. }
  226. }
  227. /**
  228. * Test deleting message when there is no trash mailbox
  229. */
  230. public void testDeleteMessageNoTrash() {
  231. Account account1 =
  232. ProviderTestUtils.setupAccount("message-delete-notrash", true, mProviderContext);
  233. long account1Id = account1.mId;
  234. Mailbox box1 = ProviderTestUtils.setupMailbox("box1", account1Id, true, mProviderContext);
  235. long box1Id = box1.mId;
  236. Message message1 =
  237. ProviderTestUtils.setupMessage("message1", account1Id, box1Id, false, true,
  238. mProviderContext);
  239. long message1Id = message1.mId;
  240. mTestController.deleteMessageSync(message1Id);
  241. // now read back a fresh copy and confirm it's in the trash
  242. Message message1get =
  243. EmailContent.Message.restoreMessageWithId(mProviderContext, message1Id);
  244. // check the new mailbox and see if it looks right
  245. assertFalse(-1 == message1get.mMailboxKey);
  246. assertFalse(box1Id == message1get.mMailboxKey);
  247. Mailbox mailbox2get = Mailbox.restoreMailboxWithId(mProviderContext,
  248. message1get.mMailboxKey);
  249. assertEquals(Mailbox.TYPE_TRASH, mailbox2get.mType);
  250. }
  251. /**
  252. * Test read/unread flag
  253. */
  254. public void testReadUnread() throws InterruptedException, ExecutionException {
  255. Account account1 = ProviderTestUtils.setupAccount("read-unread", false, mProviderContext);
  256. account1.mHostAuthRecv
  257. = ProviderTestUtils.setupHostAuth("read-unread", 0, false, mProviderContext);
  258. account1.save(mProviderContext);
  259. long account1Id = account1.mId;
  260. long box1Id = 2;
  261. Message message1 =
  262. ProviderTestUtils.setupMessage("message1", account1Id, box1Id, false, true,
  263. mProviderContext);
  264. long message1Id = message1.mId;
  265. // test setting to "read"
  266. mTestController.setMessageRead(message1Id, true).get();
  267. Message message1get = Message.restoreMessageWithId(mProviderContext, message1Id);
  268. assertTrue(message1get.mFlagRead);
  269. // test setting to "unread"
  270. mTestController.setMessageRead(message1Id, false).get();
  271. message1get = Message.restoreMessageWithId(mProviderContext, message1Id);
  272. assertFalse(message1get.mFlagRead);
  273. // test setting to "read"
  274. mTestController.setMessageRead(message1Id, true).get();
  275. message1get = Message.restoreMessageWithId(mProviderContext, message1Id);
  276. assertTrue(message1get.mFlagRead);
  277. }
  278. /**
  279. * Test favorites flag
  280. */
  281. public void testFavorites() throws InterruptedException, ExecutionException {
  282. Account account1 = ProviderTestUtils.setupAccount("favorites", false, mProviderContext);
  283. account1.mHostAuthRecv
  284. = ProviderTestUtils.setupHostAuth("favorites", 0, false, mProviderContext);
  285. account1.save(mProviderContext);
  286. long account1Id = account1.mId;
  287. long box1Id = 2;
  288. Message message1 =
  289. ProviderTestUtils.setupMessage("message1", account1Id, box1Id, false, true,
  290. mProviderContext);
  291. long message1Id = message1.mId;
  292. // test setting to "favorite"
  293. mTestController.setMessageFavorite(message1Id, true).get();
  294. Message message1get = Message.restoreMessageWithId(mProviderContext, message1Id);
  295. assertTrue(message1get.mFlagFavorite);
  296. // test setting to "not favorite"
  297. mTestController.setMessageFavorite(message1Id, false).get();
  298. message1get = Message.restoreMessageWithId(mProviderContext, message1Id);
  299. assertFalse(message1get.mFlagFavorite);
  300. // test setting to "favorite"
  301. mTestController.setMessageFavorite(message1Id, true).get();
  302. message1get = Message.restoreMessageWithId(mProviderContext, message1Id);
  303. assertTrue(message1get.mFlagFavorite);
  304. }
  305. public void testGetAndDeleteAttachmentMailbox() {
  306. Mailbox box = mTestController.getAttachmentMailbox();
  307. assertNotNull(box);
  308. Mailbox anotherBox = mTestController.getAttachmentMailbox();
  309. assertNotNull(anotherBox);
  310. // We should always get back the same Mailbox row
  311. assertEquals(box.mId, anotherBox.mId);
  312. // Add two messages to this mailbox
  313. ProviderTestUtils.setupMessage("message1", 0, box.mId, false, true,
  314. mProviderContext);
  315. ProviderTestUtils.setupMessage("message2", 0, box.mId, false, true,
  316. mProviderContext);
  317. // Make sure we can find them where they are expected
  318. assertEquals(2, EmailContent.count(mProviderContext, Message.CONTENT_URI,
  319. Message.MAILBOX_KEY + "=?", new String[] {Long.toString(box.mId)}));
  320. // Delete them
  321. mTestController.deleteAttachmentMessages();
  322. // Make sure they're gone
  323. assertEquals(0, EmailContent.count(mProviderContext, Message.CONTENT_URI,
  324. Message.MAILBOX_KEY + "=?", new String[] {Long.toString(box.mId)}));
  325. }
  326. /**
  327. * Test wiping an account's synced data. Everything should go, but account & empty inbox.
  328. * Also ensures that the remaining account and the remaining inbox have cleared their
  329. * server sync keys, to force refresh eventually.
  330. */
  331. public void testWipeSyncedData() {
  332. Account account1 = ProviderTestUtils.setupAccount("wipe-synced-1", false, mProviderContext);
  333. account1.mSyncKey = "account-1-sync-key";
  334. account1.save(mProviderContext);
  335. long account1Id = account1.mId;
  336. Mailbox box1 = ProviderTestUtils.setupMailbox("box1", account1Id, false, mProviderContext);
  337. box1.mType = Mailbox.TYPE_INBOX;
  338. box1.mSyncKey = "box-1-sync-key";
  339. box1.save(mProviderContext);
  340. long box1Id = box1.mId;
  341. Mailbox box2 = ProviderTestUtils.setupMailbox("box2", account1Id, true, mProviderContext);
  342. long box2Id = box2.mId;
  343. // An EAS account mailbox
  344. Mailbox eas = ProviderTestUtils.setupMailbox("eas", account1Id, false, mProviderContext);
  345. eas.mType = Mailbox.TYPE_EAS_ACCOUNT_MAILBOX;
  346. eas.save(mProviderContext);
  347. Account account2 = ProviderTestUtils.setupAccount("wipe-synced-2", false, mProviderContext);
  348. account2.mSyncKey = "account-2-sync-key";
  349. account2.save(mProviderContext);
  350. long account2Id = account2.mId;
  351. Mailbox box3 = ProviderTestUtils.setupMailbox("box3", account2Id, false, mProviderContext);
  352. box3.mSyncKey = "box-3-sync-key";
  353. box3.mType = Mailbox.TYPE_INBOX;
  354. box3.save(mProviderContext);
  355. long box3Id = box3.mId;
  356. Mailbox box4 = ProviderTestUtils.setupMailbox("box4", account2Id, true, mProviderContext);
  357. long box4Id = box4.mId;
  358. // Now populate the 4 non-account boxes with messages
  359. Message message = ProviderTestUtils.setupMessage("message1", account1Id, box1Id, false,
  360. true, mProviderContext);
  361. long message1Id = message.mId;
  362. message = ProviderTestUtils.setupMessage("message2", account1Id, box2Id, false,
  363. true, mProviderContext);
  364. long message2Id = message.mId;
  365. message = ProviderTestUtils.setupMessage("message3", account2Id, box3Id, false,
  366. true, mProviderContext);
  367. long message3Id = message.mId;
  368. message = ProviderTestUtils.setupMessage("message4", account2Id, box4Id, false,
  369. true, mProviderContext);
  370. long message4Id = message.mId;
  371. // Now wipe account 1's data
  372. mTestController.deleteSyncedDataSync(account1Id);
  373. // Confirm: Mailboxes gone (except account box), all messages gone, account survives
  374. assertNull(Mailbox.restoreMailboxWithId(mProviderContext, box1Id));
  375. assertNull(Mailbox.restoreMailboxWithId(mProviderContext, box2Id));
  376. assertNotNull(Mailbox.restoreMailboxWithId(mProviderContext, eas.mId));
  377. assertNull(Message.restoreMessageWithId(mProviderContext, message1Id));
  378. assertNull(Message.restoreMessageWithId(mProviderContext, message2Id));
  379. account1 = Account.restoreAccountWithId(mProviderContext, account1Id);
  380. assertNotNull(account1);
  381. assertNull(account1.mSyncKey);
  382. // Confirm: Other account survived
  383. assertNotNull(Mailbox.restoreMailboxWithId(mProviderContext, box3Id));
  384. assertNotNull(Mailbox.restoreMailboxWithId(mProviderContext, box4Id));
  385. assertNotNull(Message.restoreMessageWithId(mProviderContext, message3Id));
  386. assertNotNull(Message.restoreMessageWithId(mProviderContext, message4Id));
  387. assertNotNull(Account.restoreAccountWithId(mProviderContext, account2Id));
  388. }
  389. public void testLoadMessageFromUri() throws Exception {
  390. // Create a simple message
  391. Message msg = new Message();
  392. String text = "This is some text";
  393. msg.mText = text;
  394. String sender = "sender@host.com";
  395. msg.mFrom = sender;
  396. // Save this away
  397. msg.save(mProviderContext);
  398. Uri fileUri = ProviderTestUtils.createTempEmlFile(mProviderContext, msg,
  399. mContext.getFilesDir());
  400. // Load the message via Controller and a Uri
  401. Message loadedMsg = mTestController.loadMessageFromUri(fileUri);
  402. // Check server id, mailbox key, account key, and from
  403. assertNotNull(loadedMsg);
  404. assertTrue(loadedMsg.mServerId.startsWith(Controller.ATTACHMENT_MESSAGE_UID_PREFIX));
  405. Mailbox box = mTestController.getAttachmentMailbox();
  406. assertNotNull(box);
  407. assertEquals(box.mId, loadedMsg.mMailboxKey);
  408. assertEquals(0, loadedMsg.mAccountKey);
  409. assertEquals(loadedMsg.mFrom, sender);
  410. // Check body text
  411. String loadedMsgText = Body.restoreBodyTextWithMessageId(mProviderContext, loadedMsg.mId);
  412. assertEquals(text, loadedMsgText);
  413. }
  414. /**
  415. * Create a simple HostAuth with protocol
  416. */
  417. private HostAuth setupSimpleHostAuth(String protocol) {
  418. HostAuth hostAuth = new HostAuth();
  419. hostAuth.mProtocol = protocol;
  420. return hostAuth;
  421. }
  422. public void testIsMessagingController() {
  423. Account account1 = ProviderTestUtils.setupAccount("account1", false,
  424. mProviderContext);
  425. account1.mHostAuthRecv = setupSimpleHostAuth("eas");
  426. account1.save(mProviderContext);
  427. assertFalse(mTestController.isMessagingController(account1));
  428. Account account2 = ProviderTestUtils.setupAccount("account2", false,
  429. mProviderContext);
  430. account2.mHostAuthRecv = setupSimpleHostAuth("imap");
  431. account2.save(mProviderContext);
  432. assertTrue(mTestController.isMessagingController(account2));
  433. Account account3 = ProviderTestUtils.setupAccount("account3", false,
  434. mProviderContext);
  435. account3.mHostAuthRecv = setupSimpleHostAuth("pop3");
  436. account3.save(mProviderContext);
  437. assertTrue(mTestController.isMessagingController(account3));
  438. Account account4 = ProviderTestUtils.setupAccount("account4", false,
  439. mProviderContext);
  440. account4.mHostAuthRecv = setupSimpleHostAuth("smtp");
  441. account4.save(mProviderContext);
  442. assertFalse(mTestController.isMessagingController(account4));
  443. // There should be values for all of these accounts in the legacy map
  444. assertNotNull(mTestController.mLegacyControllerMap.get(account1.mId));
  445. assertNotNull(mTestController.mLegacyControllerMap.get(account2.mId));
  446. assertNotNull(mTestController.mLegacyControllerMap.get(account3.mId));
  447. assertNotNull(mTestController.mLegacyControllerMap.get(account4.mId));
  448. // The map should have the expected values
  449. assertFalse(mTestController.mLegacyControllerMap.get(account1.mId));
  450. assertTrue(mTestController.mLegacyControllerMap.get(account2.mId));
  451. assertTrue(mTestController.mLegacyControllerMap.get(account3.mId));
  452. assertFalse(mTestController.mLegacyControllerMap.get(account4.mId));
  453. // This second pass should pull values from the cache
  454. assertFalse(mTestController.isMessagingController(account1));
  455. assertTrue(mTestController.isMessagingController(account2));
  456. assertTrue(mTestController.isMessagingController(account3));
  457. assertFalse(mTestController.isMessagingController(account4));
  458. }
  459. /**
  460. * TODO: releasing associated data (e.g. attachments, embedded images)
  461. */
  462. }