public void testGetServiceForMailbox() throws Exception { ArrayList<Long> iList = setupAccountMailboxAndMessages(2); Body body = EmailContentSetupUtils.setupBody( "body", iList.get(0), iList.get(1), true, mProviderContext); setupSyncParserAndAdapter(mAccount, mMailbox); EasSyncService service = EasSyncService.getServiceForMailbox(mProviderContext, mMailbox); Thread thread = new Thread(service); thread.start(); assertTrue(service instanceof EasOutboxService); mMailbox.mType = Mailbox.TYPE_EAS_ACCOUNT_MAILBOX; service = EasSyncService.getServiceForMailbox(mProviderContext, mMailbox); assertTrue(service instanceof EasAccountService); mMailbox.mType = Mailbox.TYPE_INBOX; service = EasSyncService.getServiceForMailbox(mProviderContext, mMailbox); assertTrue(service instanceof EasSyncService); TestUtils.sleepAndWait(5000); }
ArrayList<Long> setupAccountMailboxAndMessages(int numMessages) { ArrayList<Long> ids = new ArrayList<Long>(); String expected = "6" + '\2' + "UID" + '\1' + "2012-01-02T23:00:01.000Z" + '\2' + "DTSTAMP" + '\1' + "7" + '\2' + "RESPONSE" + '\1' + "*****@*****.**" + '\2' + "ORGMAIL" + '\1' + "2012-01-02T23:00:01.000Z" + '\2' + "DTSTART" + '\1' + "1" + '\2' + "ALLDAY" + '\1' + "2012-01-02T24:00:01.000Z" + '\2' + "DTEND" + '\1' + "8" + '\2' + "TITLE" + '\1' + "5" + '\2' + "LOC"; // Create account and two mailboxes mAccount = EmailContentSetupUtils.setupEasAccount("account", true, mProviderContext, "14.1"); mMailbox = EmailContentSetupUtils.setupMailbox( "box1", mAccount.mId, true, mProviderContext, Mailbox.TYPE_OUTBOX, null); for (int i = 0; i < numMessages; i++) { Message msg = setupMessage( "message" + i, mAccount.mId, mMailbox.mId, expected, false, true, mProviderContext, true, true); ids.add(msg.mId); } return ids; }