Lines Matching refs:Mailbox
40 * Unit tests for the Mailbox inner class.
72 /** Returns the number of messages in a mailbox. */
75 ContentUris.withAppendedId(Mailbox.CONTENT_URI, mailboxId),
80 private static Message createMessage(Context c, Mailbox b, boolean starred, boolean read,
94 * Test simple mailbox save/retrieve
99 Account account1 = ProviderTestUtils.setupAccount("mailbox-save", true, c);
101 Mailbox box1 = ProviderTestUtils.setupMailbox("box1", account1Id, true, c);
104 Mailbox box2 = Mailbox.restoreMailboxWithId(c, box1Id);
110 * Test delete mailbox
115 Account account1 = ProviderTestUtils.setupAccount("mailbox-delete", true, c);
117 Mailbox box1 = ProviderTestUtils.setupMailbox("box1", account1Id, true, c);
119 Mailbox box2 = ProviderTestUtils.setupMailbox("box2", account1Id, true, c);
126 int numBoxes = EmailContent.count(c, Mailbox.CONTENT_URI, selection, selArgs);
130 Uri uri = ContentUris.withAppendedId(Mailbox.CONTENT_URI, box1Id);
133 // make sure there's only one mailbox now
134 numBoxes = EmailContent.count(c, Mailbox.CONTENT_URI, selection, selArgs);
138 uri = ContentUris.withAppendedId(Mailbox.CONTENT_URI, box2Id);
142 numBoxes = EmailContent.count(c, Mailbox.CONTENT_URI, selection, selArgs);
150 Mailbox bi = ProviderTestUtils.setupMailbox("b1", a.mId, true, c, Mailbox.TYPE_INBOX);
151 Mailbox bm = ProviderTestUtils.setupMailbox("b2", a.mId, true, c, Mailbox.TYPE_MAIL);
153 assertEquals(Mailbox.TYPE_INBOX, Mailbox.getMailboxType(c, bi.mId));
154 assertEquals(Mailbox.TYPE_MAIL, Mailbox.getMailboxType(c, bm.mId));
155 assertEquals(-1, Mailbox.getMailboxType(c, 999999)); // mailbox not found
162 Mailbox bi = ProviderTestUtils.setupMailbox("b1", a.mId, true, c, Mailbox.TYPE_INBOX);
163 Mailbox bm = ProviderTestUtils.setupMailbox("b2", a.mId, true, c, Mailbox.TYPE_MAIL);
165 assertEquals("b1", Mailbox.getDisplayName(c, bi.mId));
166 assertEquals("b2", Mailbox.getDisplayName(c, bm.mId));
167 assertEquals(null, Mailbox.getDisplayName(c, 999999)); // mailbox not found
174 Mailbox bi = ProviderTestUtils.setupMailbox("b1", a.mId, true, c, Mailbox.TYPE_INBOX);
175 Mailbox bm = ProviderTestUtils.setupMailbox("b1", a.mId, true, c, Mailbox.TYPE_MAIL);
176 Mailbox bd = ProviderTestUtils.setupMailbox("b1", a.mId, true, c, Mailbox.TYPE_DRAFTS);
177 Mailbox bo = ProviderTestUtils.setupMailbox("b1", a.mId, true, c, Mailbox.TYPE_OUTBOX);
179 assertTrue(Mailbox.isRefreshable(c, bi.mId));
180 assertTrue(Mailbox.isRefreshable(c, bm.mId));
181 assertFalse(Mailbox.isRefreshable(c, bd.mId));
182 assertFalse(Mailbox.isRefreshable(c, bo.mId));
184 // No such mailbox
185 assertFalse(Mailbox.isRefreshable(c, 9999999));
188 assertFalse(Mailbox.isRefreshable(c, Mailbox.QUERY_ALL_DRAFTS));
189 assertFalse(Mailbox.isRefreshable(c, Mailbox.QUERY_ALL_INBOXES));
196 Mailbox bi = ProviderTestUtils.setupMailbox("b1", a.mId, true, c, Mailbox.TYPE_INBOX);
197 Mailbox bm = ProviderTestUtils.setupMailbox("b1", a.mId, true, c, Mailbox.TYPE_MAIL);
198 Mailbox bd = ProviderTestUtils.setupMailbox("b1", a.mId, true, c, Mailbox.TYPE_DRAFTS);
199 Mailbox bo = ProviderTestUtils.setupMailbox("b1", a.mId, true, c, Mailbox.TYPE_OUTBOX);
209 Mailbox b1 = ProviderTestUtils.setupMailbox("box1", 1, true, c, Mailbox.TYPE_MAIL);
210 Mailbox b2 = ProviderTestUtils.setupMailbox("box2", 1, true, c, Mailbox.TYPE_MAIL);
215 ProviderTestUtils.assertMailboxEqual("x", b1, Mailbox.getMailboxForMessageId(c, m1.mId));
216 ProviderTestUtils.assertMailboxEqual("x", b2, Mailbox.getMailboxForMessageId(c, m2.mId));
221 Mailbox testMailbox;
223 testMailbox = ProviderTestUtils.setupMailbox("box1", 1, true, c, Mailbox.TYPE_MAIL);
225 "x", testMailbox, Mailbox.restoreMailboxWithId(c, testMailbox.mId));
226 testMailbox = ProviderTestUtils.setupMailbox("box2", 1, true, c, Mailbox.TYPE_MAIL);
228 "x", testMailbox, Mailbox.restoreMailboxWithId(c, testMailbox.mId));
230 assertNull(Mailbox.restoreMailboxWithId(c, 8));
231 assertNull(Mailbox.restoreMailboxWithId(c, -1));
232 assertNull(Mailbox.restoreMailboxWithId(c, Long.MAX_VALUE));
237 Mailbox testMailbox;
238 testMailbox = ProviderTestUtils.setupMailbox("a/b/c/box", 1, true, c, Mailbox.TYPE_MAIL);
240 "x", testMailbox, Mailbox.restoreMailboxForPath(c, 1, "a/b/c/box"));
242 assertNull(Mailbox.restoreMailboxForPath(c, 2, "a/b/c/box"));
244 assertNull(Mailbox.restoreMailboxForPath(c, 1, "a/b/c"));
246 assertNull(Mailbox.restoreMailboxForPath(c, 1, "a/b/c/%"));
252 // Create two accounts and a variety of mailbox types
254 Mailbox acct1Inbox =
255 ProviderTestUtils.setupMailbox("Inbox1", acct1.mId, true, context, Mailbox.TYPE_INBOX);
256 Mailbox acct1Calendar =
257 ProviderTestUtils.setupMailbox("Cal1", acct1.mId, true, context, Mailbox.TYPE_CALENDAR);
258 Mailbox acct1Contacts =
259 ProviderTestUtils.setupMailbox("Con1", acct1.mId, true, context, Mailbox.TYPE_CONTACTS);
261 Mailbox acct2Inbox =
262 ProviderTestUtils.setupMailbox("Inbox2", acct2.mId, true, context, Mailbox.TYPE_INBOX);
263 Mailbox acct2Calendar =
264 ProviderTestUtils.setupMailbox("Cal2", acct2.mId, true, context, Mailbox.TYPE_CALENDAR);
265 Mailbox acct2Contacts =
266 ProviderTestUtils.setupMailbox("Con2", acct2.mId, true, context, Mailbox.TYPE_CONTACTS);
270 Mailbox.findMailboxOfType(context, acct1.mId, Mailbox.TYPE_INBOX));
272 Mailbox.findMailboxOfType(context, acct2.mId, Mailbox.TYPE_INBOX));
274 Mailbox.findMailboxOfType(context, acct1.mId, Mailbox.TYPE_CALENDAR));
276 Mailbox.findMailboxOfType(context, acct2.mId, Mailbox.TYPE_CALENDAR));
278 Mailbox.findMailboxOfType(context, acct1.mId, Mailbox.TYPE_CONTACTS));
280 Mailbox.findMailboxOfType(context, acct2.mId, Mailbox.TYPE_CONTACTS));
283 assertEquals(Mailbox.NO_MAILBOX,
284 Mailbox.findMailboxOfType(context, acct1.mId, Mailbox.TYPE_DRAFTS));
285 assertEquals(Mailbox.NO_MAILBOX,
286 Mailbox.findMailboxOfType(context, acct1.mId, Mailbox.TYPE_OUTBOX));
291 assertEquals(Mailbox.NO_MAILBOX,
292 Mailbox.findMailboxOfType(context, acct1.mId, Mailbox.TYPE_INBOX));
293 assertEquals(Mailbox.NO_MAILBOX,
294 Mailbox.findMailboxOfType(context, acct1.mId, Mailbox.TYPE_CALENDAR));
295 assertEquals(Mailbox.NO_MAILBOX,
296 Mailbox.findMailboxOfType(context, acct1.mId, Mailbox.TYPE_CONTACTS));
302 // Create two accounts and a variety of mailbox types
304 Mailbox acct1Inbox =
305 ProviderTestUtils.setupMailbox("Inbox1", acct1.mId, true, context, Mailbox.TYPE_INBOX);
306 Mailbox acct1Calendar =
307 ProviderTestUtils.setupMailbox("Cal1", acct1.mId, true, context, Mailbox.TYPE_CALENDAR);
308 Mailbox acct1Contacts =
309 ProviderTestUtils.setupMailbox("Con1", acct1.mId, true, context, Mailbox.TYPE_CONTACTS);
311 Mailbox acct2Inbox =
312 ProviderTestUtils.setupMailbox("Inbox2", acct2.mId, true, context, Mailbox.TYPE_INBOX);
313 Mailbox acct2Calendar =
314 ProviderTestUtils.setupMailbox("Cal2", acct2.mId, true, context, Mailbox.TYPE_CALENDAR);
315 Mailbox acct2Contacts =
316 ProviderTestUtils.setupMailbox("Con2", acct2.mId, true, context, Mailbox.TYPE_CONTACTS);
320 Mailbox.restoreMailboxOfType(context, acct1.mId, Mailbox.TYPE_INBOX));
322 Mailbox.restoreMailboxOfType(context, acct2.mId, Mailbox.TYPE_INBOX));
324 Mailbox.restoreMailboxOfType(context, acct1.mId, Mailbox.TYPE_CALENDAR));
326 Mailbox.restoreMailboxOfType(context, acct2.mId, Mailbox.TYPE_CALENDAR));
328 Mailbox.restoreMailboxOfType(context, acct1.mId, Mailbox.TYPE_CONTACTS));
330 Mailbox.restoreMailboxOfType(context, acct2.mId, Mailbox.TYPE_CONTACTS));
334 * Test for the message count triggers (insert/delete/move mailbox), and also
349 Mailbox b1 = ProviderTestUtils.setupMailbox("box1", a1.mId, true, c, Mailbox.TYPE_INBOX);
350 Mailbox b2 = ProviderTestUtils.setupMailbox("box2", a1.mId, true, c, Mailbox.TYPE_OUTBOX);
351 MailboxMailbox.TYPE_INBOX);
352 Mailbox b4 = ProviderTestUtils.setupMailbox("box4", a2.mId, true, c, Mailbox.TYPE_OUTBOX);
353 Mailbox bt = ProviderTestUtils.setupMailbox("boxT", a2.mId, true, c, Mailbox.TYPE_TRASH);
401 // 2. Check the "move mailbox" trigger.
403 // Move m32 (in mailbox 3) to mailbox 4.
418 // Delete m11 (in mailbox 1)
421 // Delete m21 (in mailbox 2)
432 private Mailbox buildTestMailbox(String serverId) {
436 private Mailbox buildTestMailbox(String serverId, String name) {
437 Mailbox testMailbox = new Mailbox();
459 Mailbox testMailbox = buildTestMailbox(TEST_SERVER_ID);
493 Mailbox original = buildTestMailbox("serverId", "display name for mailbox");
501 Mailbox unparcelled = Mailbox.CREATOR.createFromParcel(p);
504 Mailbox phony = buildTestMailbox("different ID", "display name for mailbox");
511 Mailbox unpopulated = new Mailbox();
520 Mailbox unparcelled = Mailbox.CREATOR.createFromParcel(p);