diff options
author | Régis Décamps <regisd@google.com> | 2014-10-08 14:15:22 +0200 |
---|---|---|
committer | Régis Décamps <regisd@google.com> | 2014-10-09 14:36:41 +0200 |
commit | 3799895916df4df036dbd6c5dd011c28e10a6f11 (patch) | |
tree | 14943a01a9b17a0151be14a059010b5bdaf3590d /tests | |
parent | 9e700c59ccd35fb243fbfa207b530d4184d7ad3a (diff) | |
download | android_packages_apps_UnifiedEmail-3799895916df4df036dbd6c5dd011c28e10a6f11.tar.gz android_packages_apps_UnifiedEmail-3799895916df4df036dbd6c5dd011c28e10a6f11.tar.bz2 android_packages_apps_UnifiedEmail-3799895916df4df036dbd6c5dd011c28e10a6f11.zip |
Fix ComposeActivityTest
Fix `Can't create handler inside thread that has not called
Looper.prepare()`.
`new FromAddressSpinner(activity);` needs to be called on the UI
thread.
Bug: 9823857 Add unit test for merging accounts in from spinner
Bug: 17388964 Fix the Gmail test suite
Change-Id: Icbc9ae309a59cbe5f6ed6cd0681747b3e37e0157
Diffstat (limited to 'tests')
-rw-r--r-- | tests/src/com/android/mail/compose/ComposeActivityTest.java | 75 |
1 files changed, 44 insertions, 31 deletions
diff --git a/tests/src/com/android/mail/compose/ComposeActivityTest.java b/tests/src/com/android/mail/compose/ComposeActivityTest.java index ee2ae25cb..58d90aa94 100644 --- a/tests/src/com/android/mail/compose/ComposeActivityTest.java +++ b/tests/src/com/android/mail/compose/ComposeActivityTest.java @@ -137,21 +137,22 @@ public class ComposeActivityTest extends ActivityInstrumentationTestCase2<Compos + "someotheraccount2@mockuiprovider.com, someotheraccount3@mockuiprovider.com, " + customFrom); refMessage.setReplyTo(customFrom); - activity.mFromSpinner = new FromAddressSpinner(activity); + ReplyFromAccount a = new ReplyFromAccount(mAccount, mAccount.uri, customFrom, customFrom, customFrom, true, true); JSONArray array = new JSONArray(); array.put(a.serialize()); mAccount.accountFromAddresses = array.toString(); - ReplyFromAccount currentAccount = new ReplyFromAccount(mAccount, mAccount.uri, + final ReplyFromAccount currentAccount = new ReplyFromAccount(mAccount, mAccount.uri, mAccount.getEmailAddress(), mAccount.getEmailAddress(), customFrom, true, false); - activity.mFromSpinner.setCurrentAccount(currentAccount); - - activity.mFromSpinner.initialize(ComposeActivity.REPLY_ALL, - currentAccount.account, EMPTY_ACCOUNT_LIST, null); runTestOnUiThread(new Runnable() { @Override public void run() { + activity.mFromSpinner = new FromAddressSpinner(activity); + activity.mFromSpinner.setCurrentAccount(currentAccount); + activity.mFromSpinner.initialize(ComposeActivity.REPLY_ALL, + currentAccount.account, EMPTY_ACCOUNT_LIST, null); + activity.initReplyRecipients(refMessage, ComposeActivity.REPLY_ALL); String[] to = activity.getToAddresses(); String[] cc = activity.getCcAddresses(); @@ -176,17 +177,19 @@ public class ComposeActivityTest extends ActivityInstrumentationTestCase2<Compos refMessage.setFrom("account3@mockuiprovider.com"); refMessage.setTo("account3@mockuiprovider.com"); final Account account = mAccount; - activity.mFromSpinner = new FromAddressSpinner(activity); - ReplyFromAccount currentAccount = new ReplyFromAccount(mAccount, mAccount.uri, + + final ReplyFromAccount currentAccount = new ReplyFromAccount(mAccount, mAccount.uri, mAccount.getEmailAddress(), mAccount.getEmailAddress(), mAccount.getEmailAddress(), true, false); - activity.mFromSpinner.setCurrentAccount(currentAccount); - activity.mFromSpinner.initialize(ComposeActivity.REPLY_ALL, - currentAccount.account, EMPTY_ACCOUNT_LIST, null); runTestOnUiThread(new Runnable() { @Override public void run() { + activity.mFromSpinner = new FromAddressSpinner(activity); + activity.mFromSpinner.setCurrentAccount(currentAccount); + activity.mFromSpinner.initialize(ComposeActivity.REPLY_ALL, + currentAccount.account, EMPTY_ACCOUNT_LIST, null); + activity.initReplyRecipients(refMessage, ComposeActivity.REPLY_ALL); String[] to = activity.getToAddresses(); String[] cc = activity.getCcAddresses(); @@ -211,21 +214,23 @@ public class ComposeActivityTest extends ActivityInstrumentationTestCase2<Compos final String customFrom = "CUSTOMaccount3@mockuiprovider.com"; refMessage.setFrom("account3@mockuiprovider.com"); refMessage.setTo(customFrom); - activity.mFromSpinner = new FromAddressSpinner(activity); + ReplyFromAccount a = new ReplyFromAccount(mAccount, mAccount.uri, customFrom, customFrom, customFrom, true, true); JSONArray array = new JSONArray(); array.put(a.serialize()); mAccount.accountFromAddresses = array.toString(); - ReplyFromAccount currentAccount = new ReplyFromAccount(mAccount, mAccount.uri, + final ReplyFromAccount currentAccount = new ReplyFromAccount(mAccount, mAccount.uri, mAccount.getEmailAddress(), mAccount.getEmailAddress(), customFrom, true, false); - activity.mFromSpinner.setCurrentAccount(currentAccount); - activity.mFromSpinner.initialize(ComposeActivity.REPLY_ALL, - currentAccount.account, EMPTY_ACCOUNT_LIST, null); runTestOnUiThread(new Runnable() { @Override public void run() { + activity.mFromSpinner = new FromAddressSpinner(activity); + activity.mFromSpinner.setCurrentAccount(currentAccount); + activity.mFromSpinner.initialize(ComposeActivity.REPLY_ALL, + currentAccount.account, EMPTY_ACCOUNT_LIST, null); + activity.initReplyRecipients(refMessage, ComposeActivity.REPLY_ALL); String[] to = activity.getToAddresses(); String[] cc = activity.getCcAddresses(); @@ -540,22 +545,24 @@ public class ComposeActivityTest extends ActivityInstrumentationTestCase2<Compos final Message refMessage = getRefMessage(activity.getContentResolver()); refMessage.setFrom("CUSTOMaccount1@mockuiprovider.com"); refMessage.setTo("someotheraccount@mockuiprovider.com"); - activity.mFromSpinner = new FromAddressSpinner(activity); + ReplyFromAccount a = new ReplyFromAccount(mAccount, mAccount.uri, refMessage.getFrom(), refMessage.getFrom(), refMessage.getFrom(), true, true); JSONArray array = new JSONArray(); array.put(a.serialize()); mAccount.accountFromAddresses = array.toString(); - ReplyFromAccount currentAccount = new ReplyFromAccount(mAccount, mAccount.uri, + final ReplyFromAccount currentAccount = new ReplyFromAccount(mAccount, mAccount.uri, mAccount.getEmailAddress(), mAccount.getEmailAddress(), mAccount.getEmailAddress(), true, false); - activity.mFromSpinner.setCurrentAccount(currentAccount); - activity.mFromSpinner.initialize(ComposeActivity.REPLY, currentAccount.account, - EMPTY_ACCOUNT_LIST, null); runTestOnUiThread(new Runnable() { @Override public void run() { + activity.mFromSpinner = new FromAddressSpinner(activity); + activity.mFromSpinner.setCurrentAccount(currentAccount); + activity.mFromSpinner.initialize(ComposeActivity.REPLY, currentAccount.account, + EMPTY_ACCOUNT_LIST, null); + activity.initReplyRecipients(refMessage, ComposeActivity.REPLY); String[] to = activity.getToAddresses(); String[] cc = activity.getCcAddresses(); @@ -581,21 +588,24 @@ public class ComposeActivityTest extends ActivityInstrumentationTestCase2<Compos refMessage.setTo("someotheraccount@mockuiprovider.com, " + "someotheraccount2@mockuiprovider.com, someotheraccount4@mockuiprovider.com, " + customFrom); - activity.mFromSpinner = new FromAddressSpinner(activity); + ReplyFromAccount a = new ReplyFromAccount(mAccount, mAccount.uri, customFrom, customFrom, customFrom, true, true); JSONArray array = new JSONArray(); array.put(a.serialize()); mAccount.accountFromAddresses = array.toString(); - ReplyFromAccount currentAccount = new ReplyFromAccount(mAccount, mAccount.uri, + final ReplyFromAccount currentAccount = new ReplyFromAccount(mAccount, mAccount.uri, mAccount.getEmailAddress(), mAccount.getEmailAddress(), mAccount.getEmailAddress(), true, false); - activity.mFromSpinner.setCurrentAccount(currentAccount); - activity.mFromSpinner.initialize(ComposeActivity.REPLY_ALL, - currentAccount.account, EMPTY_ACCOUNT_LIST, null); + runTestOnUiThread(new Runnable() { @Override public void run() { + activity.mFromSpinner = new FromAddressSpinner(activity); + activity.mFromSpinner.setCurrentAccount(currentAccount); + activity.mFromSpinner.initialize(ComposeActivity.REPLY_ALL, + currentAccount.account, EMPTY_ACCOUNT_LIST, null); + activity.initReplyRecipients(refMessage, ComposeActivity.REPLY_ALL); String[] to = activity.getToAddresses(); String[] cc = activity.getCcAddresses(); @@ -624,21 +634,24 @@ public class ComposeActivityTest extends ActivityInstrumentationTestCase2<Compos refMessage.setTo("someotheraccount@mockuiprovider.com, " + "someotheraccount2@mockuiprovider.com, someotheraccount4@mockuiprovider.com, " + customFrom); - activity.mFromSpinner = new FromAddressSpinner(activity); + ReplyFromAccount a = new ReplyFromAccount(mAccount, mAccount.uri, customFrom, customFrom, customFrom, true, true); JSONArray array = new JSONArray(); array.put(a.serialize()); mAccount.accountFromAddresses = array.toString(); - ReplyFromAccount currentAccount = new ReplyFromAccount(mAccount, mAccount.uri, + final ReplyFromAccount currentAccount = new ReplyFromAccount(mAccount, mAccount.uri, mAccount.getEmailAddress(), mAccount.getEmailAddress(), mAccount.getEmailAddress(), true, false); - activity.mFromSpinner.setCurrentAccount(currentAccount); - activity.mFromSpinner.initialize(ComposeActivity.REPLY_ALL, - currentAccount.account, EMPTY_ACCOUNT_LIST, null); + runTestOnUiThread(new Runnable() { @Override public void run() { + activity.mFromSpinner = new FromAddressSpinner(activity); + activity.mFromSpinner.setCurrentAccount(currentAccount); + activity.mFromSpinner.initialize(ComposeActivity.REPLY_ALL, + currentAccount.account, EMPTY_ACCOUNT_LIST, null); + activity.initReplyRecipients(refMessage, ComposeActivity.REPLY_ALL); String[] to = activity.getToAddresses(); String[] cc = activity.getCcAddresses(); |