mirror of https://github.com/moparisthebest/k-9
Merge remote-tracking branch 'k9mail_pgp_mime/master'
Fixed lots of conflictspgp_mime_preparations_view
commit
4f8fc5bc5b
@ -0,0 +1,52 @@
|
||||
package com.fsck.k9.mail.internet;
|
||||
|
||||
|
||||
import com.fsck.k9.mail.Body;
|
||||
import com.fsck.k9.mail.Message;
|
||||
import com.fsck.k9.mail.MessagingException;
|
||||
import com.fsck.k9.mail.Multipart;
|
||||
import com.fsck.k9.mail.Part;
|
||||
import org.apache.james.mime4j.util.MimeUtil;
|
||||
|
||||
|
||||
public class MimeMessageHelper {
|
||||
private MimeMessageHelper() {
|
||||
}
|
||||
|
||||
public static void setBody(Part part, Body body) throws MessagingException {
|
||||
part.setBody(body);
|
||||
|
||||
if (part instanceof Message) {
|
||||
part.setHeader("MIME-Version", "1.0");
|
||||
}
|
||||
|
||||
if (body instanceof Multipart) {
|
||||
Multipart multipart = ((Multipart) body);
|
||||
multipart.setParent(part);
|
||||
String type = multipart.getContentType();
|
||||
part.setHeader(MimeHeader.HEADER_CONTENT_TYPE, type);
|
||||
if ("multipart/signed".equalsIgnoreCase(type)) {
|
||||
setEncoding(part, MimeUtil.ENC_7BIT);
|
||||
} else {
|
||||
setEncoding(part, MimeUtil.ENC_8BIT);
|
||||
}
|
||||
} else if (body instanceof TextBody) {
|
||||
String contentType = String.format("%s;\r\n charset=utf-8", part.getMimeType());
|
||||
String name = MimeUtility.getHeaderParameter(part.getContentType(), "name");
|
||||
if (name != null) {
|
||||
contentType += String.format(";\r\n name=\"%s\"", name);
|
||||
}
|
||||
part.setHeader(MimeHeader.HEADER_CONTENT_TYPE, contentType);
|
||||
|
||||
setEncoding(part, MimeUtil.ENC_8BIT);
|
||||
}
|
||||
}
|
||||
|
||||
public static void setEncoding(Part part, String encoding) throws MessagingException {
|
||||
Body body = part.getBody();
|
||||
if (body != null) {
|
||||
body.setEncoding(encoding);
|
||||
}
|
||||
part.setHeader(MimeHeader.HEADER_CONTENT_TRANSFER_ENCODING, encoding);
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package com.fsck.k9.mail.internet;
|
||||
|
||||
|
||||
import com.fsck.k9.mail.Body;
|
||||
|
||||
|
||||
/**
|
||||
* See {@link MimeUtility#decodeBody(Body)}
|
||||
*/
|
||||
public interface RawDataBody extends Body {
|
||||
String getEncoding();
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package com.fsck.k9.endtoend;
|
||||
|
||||
import com.fsck.k9.activity.setup.WelcomeMessage;
|
||||
import com.fsck.k9.endtoend.pages.WelcomeMessagePage;
|
||||
|
||||
/**
|
||||
* Creates a new IMAP account via the getting started flow.
|
||||
*/
|
||||
public class A000_WelcomeAndSetupAccountIntegrationTest extends AbstractEndToEndTest<WelcomeMessage> {
|
||||
|
||||
public A000_WelcomeAndSetupAccountIntegrationTest() {
|
||||
super(WelcomeMessage.class, false);
|
||||
}
|
||||
|
||||
public void testCreateAccount() throws Exception {
|
||||
new AccountSetupFlow(this).setupAccountFromWelcomePage(new WelcomeMessagePage());
|
||||
}
|
||||
|
||||
public void testCreateSecondAccount() throws Exception {
|
||||
new AccountSetupFlow(this).setupAccountFromWelcomePage(new WelcomeMessagePage());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,40 @@
|
||||
package com.fsck.k9.endtoend;
|
||||
|
||||
import com.fsck.k9.activity.Accounts;
|
||||
import com.fsck.k9.endtoend.framework.AccountForTest;
|
||||
import com.fsck.k9.endtoend.framework.ApplicationState;
|
||||
import com.fsck.k9.endtoend.pages.AccountsPage;
|
||||
|
||||
/**
|
||||
* Creates and removes accounts.
|
||||
*
|
||||
* Because of the way K-9 shows the start page, there must already be two accounts
|
||||
* in existence for this test to work.
|
||||
*/
|
||||
public class A010_AccountIntegrationTest extends AbstractEndToEndTest<Accounts>{
|
||||
|
||||
public A010_AccountIntegrationTest() {
|
||||
super(Accounts.class);
|
||||
}
|
||||
|
||||
public void testCreateAccountDirectly() throws Exception {
|
||||
new AccountSetupFlow(this).setupAccountFromAccountsPage(new AccountsPage());
|
||||
}
|
||||
|
||||
public void testDeleteAccount() {
|
||||
|
||||
AccountsPage accountsPage = new AccountsPage();
|
||||
|
||||
AccountForTest accountForTest = ApplicationState.getInstance().accounts.get(0);
|
||||
accountsPage.assertAccountExists(accountForTest.description);
|
||||
|
||||
accountsPage.clickLongOnAccount(accountForTest);
|
||||
|
||||
accountsPage.clickRemoveInAccountMenu();
|
||||
|
||||
accountsPage.clickOK();
|
||||
|
||||
accountsPage.assertAccountDoesNotExist(accountForTest.description);
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
package com.fsck.k9.endtoend;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.test.ActivityInstrumentationTestCase2;
|
||||
import android.util.Log;
|
||||
|
||||
import com.fsck.k9.R;
|
||||
import com.fsck.k9.endtoend.framework.ApplicationState;
|
||||
import com.fsck.k9.endtoend.framework.StubMailServer;
|
||||
import com.fsck.k9.endtoend.pages.WelcomeMessagePage;
|
||||
import com.google.android.apps.common.testing.ui.espresso.assertion.ViewAssertions;
|
||||
|
||||
import junit.framework.AssertionFailedError;
|
||||
|
||||
import static com.google.android.apps.common.testing.ui.espresso.Espresso.onView;
|
||||
import static com.google.android.apps.common.testing.ui.espresso.matcher.ViewMatchers.withId;
|
||||
|
||||
public abstract class AbstractEndToEndTest<T extends Activity> extends ActivityInstrumentationTestCase2<T> {
|
||||
|
||||
private ApplicationState state = ApplicationState.getInstance();
|
||||
private final boolean bypassWelcome;
|
||||
|
||||
public AbstractEndToEndTest(Class<T> activityClass) {
|
||||
this(activityClass, true);
|
||||
}
|
||||
|
||||
public AbstractEndToEndTest(Class<T> activityClass, boolean bypassWelcome) {
|
||||
super(activityClass);
|
||||
this.bypassWelcome = bypassWelcome;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
getActivity();
|
||||
|
||||
if (bypassWelcome) {
|
||||
bypassWelcomeScreen();
|
||||
}
|
||||
}
|
||||
|
||||
private void bypassWelcomeScreen() {
|
||||
try {
|
||||
onView(withId(R.id.welcome_message)).check(ViewAssertions.doesNotExist());
|
||||
} catch (AssertionFailedError ex) {
|
||||
/*
|
||||
* The view doesn't NOT exist == the view exists, and needs to be bypassed!
|
||||
*/
|
||||
Log.d(getClass().getName(), "Bypassing welcome");
|
||||
new AccountSetupFlow(this).setupAccountFromWelcomePage(new WelcomeMessagePage());
|
||||
}
|
||||
}
|
||||
|
||||
protected StubMailServer setupMailServer() {
|
||||
if (null == state.stubMailServer) {
|
||||
state.stubMailServer = new StubMailServer();
|
||||
}
|
||||
return state.stubMailServer;
|
||||
}
|
||||
}
|
@ -0,0 +1,98 @@
|
||||
package com.fsck.k9.endtoend;
|
||||
|
||||
import com.fsck.k9.endtoend.framework.AccountForTest;
|
||||
import com.fsck.k9.endtoend.framework.ApplicationState;
|
||||
import com.fsck.k9.endtoend.framework.StubMailServer;
|
||||
import com.fsck.k9.endtoend.framework.UserForImap;
|
||||
import com.fsck.k9.endtoend.pages.AccountOptionsPage;
|
||||
import com.fsck.k9.endtoend.pages.AccountSetupNamesPage;
|
||||
import com.fsck.k9.endtoend.pages.AccountSetupPage;
|
||||
import com.fsck.k9.endtoend.pages.AccountTypePage;
|
||||
import com.fsck.k9.endtoend.pages.AccountsPage;
|
||||
import com.fsck.k9.endtoend.pages.IncomingServerSettingsPage;
|
||||
import com.fsck.k9.endtoend.pages.OutgoingServerSettingsPage;
|
||||
import com.fsck.k9.endtoend.pages.WelcomeMessagePage;
|
||||
import com.fsck.k9.mail.ConnectionSecurity;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Encapsulated the steps required to set up a new mail account.
|
||||
*/
|
||||
public class AccountSetupFlow {
|
||||
|
||||
static final String ACCOUNT_NAME = "sendAndReceiveTestName";
|
||||
|
||||
private final AbstractEndToEndTest test;
|
||||
|
||||
public AccountSetupFlow(AbstractEndToEndTest test) {
|
||||
this.test = test;
|
||||
}
|
||||
|
||||
public AccountsPage setupAccountFromWelcomePage(WelcomeMessagePage welcomeMessagePage) {
|
||||
AccountSetupPage accountSetupPage = welcomeMessagePage.clickNext();
|
||||
return setupAccountFromSetupNewAccountActivity(accountSetupPage);
|
||||
}
|
||||
|
||||
public AccountsPage setupAccountFromAccountsPage(AccountsPage accountPage) {
|
||||
AccountSetupPage accountSetupPage = accountPage.clickAddNewAccount();
|
||||
return setupAccountFromSetupNewAccountActivity(accountSetupPage);
|
||||
}
|
||||
|
||||
public AccountsPage setupAccountFromSetupNewAccountActivity(AccountSetupPage accountSetupPage) {
|
||||
AccountTypePage accountTypePage = fillInCredentialsAndClickManualSetup(accountSetupPage);
|
||||
|
||||
IncomingServerSettingsPage incoming = accountTypePage.clickImap();
|
||||
|
||||
StubMailServer stubMailServer = test.setupMailServer();
|
||||
|
||||
OutgoingServerSettingsPage outgoing = setupIncomingServerAndClickNext(incoming, stubMailServer);
|
||||
|
||||
AccountOptionsPage accountOptionsPage = setupOutgoingServerAndClickNext(outgoing, stubMailServer);
|
||||
|
||||
AccountSetupNamesPage accountSetupNamesPage = accountOptionsPage.clickNext();
|
||||
|
||||
String accountDescription = tempAccountName();
|
||||
accountSetupNamesPage.inputAccountDescription(accountDescription);
|
||||
accountSetupNamesPage.inputAccountName(ACCOUNT_NAME);
|
||||
|
||||
AccountsPage accountsPage = accountSetupNamesPage.clickDone();
|
||||
|
||||
accountsPage.assertAccountExists(accountDescription);
|
||||
|
||||
ApplicationState.getInstance().accounts.add(new AccountForTest(ACCOUNT_NAME, accountDescription, stubMailServer));
|
||||
|
||||
return accountsPage;
|
||||
}
|
||||
|
||||
|
||||
private String tempAccountName() {
|
||||
return "sendAndReceiveTest-" + new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'").format(new Date());
|
||||
}
|
||||
|
||||
private AccountTypePage fillInCredentialsAndClickManualSetup(AccountSetupPage page) {
|
||||
return page
|
||||
.inputEmailAddress(UserForImap.TEST_USER.emailAddress)
|
||||
.inputPassword(UserForImap.TEST_USER.password)
|
||||
.clickManualSetup();
|
||||
}
|
||||
|
||||
private AccountOptionsPage setupOutgoingServerAndClickNext(OutgoingServerSettingsPage page, StubMailServer stubMailServer) {
|
||||
return page
|
||||
.inputSmtpServer(stubMailServer.getSmtpBindAddress())
|
||||
.inputSmtpSecurity(ConnectionSecurity.NONE)
|
||||
.inputPort(stubMailServer.getSmtpPort())
|
||||
.inputRequireSignIn(false)
|
||||
.clickNext();
|
||||
}
|
||||
|
||||
private OutgoingServerSettingsPage setupIncomingServerAndClickNext(IncomingServerSettingsPage page, StubMailServer stubMailServer) {
|
||||
return page
|
||||
.inputImapServer(stubMailServer.getImapBindAddress())
|
||||
.inputImapSecurity(ConnectionSecurity.NONE)
|
||||
.inputPort(stubMailServer.getImapPort())
|
||||
.inputUsername(UserForImap.TEST_USER.loginUsername)
|
||||
.clickNext();
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package com.fsck.k9.endtoend.framework;
|
||||
|
||||
/**
|
||||
* An account that was added by a test.
|
||||
*/
|
||||
public class AccountForTest {
|
||||
|
||||
public final String name;
|
||||
public final String description;
|
||||
public final StubMailServer stubMailServer;
|
||||
|
||||
public AccountForTest(String name, String description, StubMailServer stubMailServer) {
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.stubMailServer = stubMailServer;
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package com.fsck.k9.endtoend.framework;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Stores the state of the application from the point of view of end-to-end tests.
|
||||
*/
|
||||
public class ApplicationState {
|
||||
|
||||
private static final ApplicationState state = new ApplicationState();
|
||||
|
||||
public final List<AccountForTest> accounts = new ArrayList<AccountForTest>();
|
||||
|
||||
public StubMailServer stubMailServer;
|
||||
|
||||
public static ApplicationState getInstance() {
|
||||
return state;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package com.fsck.k9.endtoend.framework;
|
||||
|
||||
import com.icegreen.greenmail.util.GreenMail;
|
||||
import com.icegreen.greenmail.util.ServerSetup;
|
||||
|
||||
/**
|
||||
* Configuration and management of a pair of stub servers for use by an account.
|
||||
*/
|
||||
public class StubMailServer {
|
||||
private static final ServerSetup IMAP_SERVER_SETUP = new ServerSetup(10143, "127.0.0.2", ServerSetup.PROTOCOL_IMAP);
|
||||
private static final ServerSetup SMTP_SERVER_SETUP = new ServerSetup(10587, "127.0.0.2", ServerSetup.PROTOCOL_SMTP);
|
||||
|
||||
/**
|
||||
* Stub server that speaks SMTP, IMAP etc., that K-9 can talk to.
|
||||
*/
|
||||
private GreenMail greenmail;
|
||||
|
||||
public StubMailServer() {
|
||||
|
||||
greenmail = new GreenMail(new ServerSetup[]{IMAP_SERVER_SETUP, SMTP_SERVER_SETUP});
|
||||
greenmail.setUser(UserForImap.TEST_USER.emailAddress, UserForImap.TEST_USER.loginUsername, UserForImap.TEST_USER.password);
|
||||
greenmail.start();
|
||||
}
|
||||
|
||||
public String getSmtpBindAddress() {
|
||||
return SMTP_SERVER_SETUP.getBindAddress();
|
||||
}
|
||||
|
||||
public int getSmtpPort() {
|
||||
return SMTP_SERVER_SETUP.getPort();
|
||||
}
|
||||
|
||||
public String getImapBindAddress() {
|
||||
return IMAP_SERVER_SETUP.getBindAddress();
|
||||
}
|
||||
|
||||
public int getImapPort() {
|
||||
return IMAP_SERVER_SETUP.getPort();
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,19 @@
|
||||
package com.fsck.k9.endtoend.framework;
|
||||
|
||||
/**
|
||||
* Credentials for the stub IMAP/SMTP server
|
||||
*/
|
||||
public class UserForImap {
|
||||
|
||||
public static final UserForImap TEST_USER = new UserForImap("test-username", "test-password", "test-email@example.com");
|
||||
|
||||
public final String loginUsername;
|
||||
public final String password;
|
||||
public final String emailAddress;
|
||||
|
||||
private UserForImap(String loginUsername, String password, String emailAddress) {
|
||||
this.loginUsername = loginUsername;
|
||||
this.password = password;
|
||||
this.emailAddress = emailAddress;
|
||||
}
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
package com.fsck.k9.endtoend.pages;
|
||||
|
||||
public class AbstractPage {
|
||||
|
||||
// used to have some content. Now a placeholder class
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package com.fsck.k9.endtoend.pages;
|
||||
|
||||
import com.fsck.k9.R;
|
||||
|
||||
import static com.google.android.apps.common.testing.ui.espresso.Espresso.onView;
|
||||
import static com.google.android.apps.common.testing.ui.espresso.action.ViewActions.click;
|
||||
import static com.google.android.apps.common.testing.ui.espresso.matcher.ViewMatchers.withId;
|
||||
|
||||
|
||||
public class AccountOptionsPage extends AbstractPage {
|
||||
|
||||
public AccountSetupNamesPage clickNext() {
|
||||
onView(withId(R.id.next)).perform(click());
|
||||
return new AccountSetupNamesPage();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
package com.fsck.k9.endtoend.pages;
|
||||
|
||||
import com.fsck.k9.R;
|
||||
import com.google.android.apps.common.testing.ui.espresso.NoMatchingViewException;
|
||||
import com.google.android.apps.common.testing.ui.espresso.matcher.ViewMatchers;
|
||||
|
||||
import static com.google.android.apps.common.testing.ui.espresso.Espresso.onView;
|
||||
import static com.google.android.apps.common.testing.ui.espresso.action.ViewActions.clearText;
|
||||
import static com.google.android.apps.common.testing.ui.espresso.action.ViewActions.click;
|
||||
import static com.google.android.apps.common.testing.ui.espresso.action.ViewActions.scrollTo;
|
||||
import static com.google.android.apps.common.testing.ui.espresso.action.ViewActions.typeText;
|
||||
import static com.google.android.apps.common.testing.ui.espresso.matcher.ViewMatchers.withId;
|
||||
|
||||
|
||||
public class AccountSetupNamesPage extends AbstractPage {
|
||||
|
||||
public AccountSetupNamesPage inputAccountName(String name) {
|
||||
onView(withId(R.id.account_name))
|
||||
.perform(scrollTo())
|
||||
.perform(clearText())
|
||||
.perform(typeText(name));
|
||||
return this;
|
||||
}
|
||||
|
||||
public AccountSetupNamesPage inputAccountDescription(String name) {
|
||||
onView(withId(R.id.account_description))
|
||||
.perform(scrollTo())
|
||||
.perform(clearText())
|
||||
.perform(typeText(name));
|
||||
return this;
|
||||
}
|
||||
|
||||
public AccountsPage clickDone() {
|
||||
onView(withId(R.id.done))
|
||||
.perform(click());
|
||||
dismissChangelog();
|
||||
return new AccountsPage();
|
||||
}
|
||||
|
||||
private void dismissChangelog() {
|
||||
try {
|
||||
onView(ViewMatchers.withText("OK")).perform(click());
|
||||
} catch (NoMatchingViewException ex) {
|
||||
// Ignored. Not the best way of doing this, but Espresso rightly makes
|
||||
// conditional flow difficult.
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package com.fsck.k9.endtoend.pages;
|
||||
|
||||
import com.fsck.k9.R;
|
||||
|
||||
import static com.google.android.apps.common.testing.ui.espresso.Espresso.onView;
|
||||
import static com.google.android.apps.common.testing.ui.espresso.action.ViewActions.click;
|
||||
import static com.google.android.apps.common.testing.ui.espresso.action.ViewActions.typeText;
|
||||
import static com.google.android.apps.common.testing.ui.espresso.matcher.ViewMatchers.withId;
|
||||
|
||||
public class AccountSetupPage extends AbstractPage {
|
||||
|
||||
public AccountSetupPage inputEmailAddress(String emailAddress) {
|
||||
onView(withId(R.id.account_email)).perform(typeText(emailAddress));
|
||||
return this;
|
||||
}
|
||||
|
||||
public AccountSetupPage inputPassword(String password) {
|
||||
onView(withId(R.id.account_password)).perform(typeText(password));
|
||||
return this;
|
||||
}
|
||||
|
||||
public AccountTypePage clickManualSetup() {
|
||||
onView(withId(R.id.manual_setup)).perform(click());
|
||||
return new AccountTypePage();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package com.fsck.k9.endtoend.pages;
|
||||
|
||||
import com.fsck.k9.R;
|
||||
|
||||
import static com.google.android.apps.common.testing.ui.espresso.Espresso.onView;
|
||||
import static com.google.android.apps.common.testing.ui.espresso.action.ViewActions.click;
|
||||
import static com.google.android.apps.common.testing.ui.espresso.matcher.ViewMatchers.withId;
|
||||
public class AccountTypePage extends AbstractPage {
|
||||
|
||||
public IncomingServerSettingsPage clickImap() {
|
||||
onView(withId(R.id.imap)).perform(click());
|
||||
return new IncomingServerSettingsPage();
|
||||
}
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
package com.fsck.k9.endtoend.pages;
|
||||
|
||||
import com.fsck.k9.R;
|
||||
import com.fsck.k9.endtoend.framework.AccountForTest;
|
||||
import com.google.android.apps.common.testing.ui.espresso.NoMatchingViewException;
|
||||
import com.google.android.apps.common.testing.ui.espresso.ViewAssertion;
|
||||
|
||||
import static com.google.android.apps.common.testing.ui.espresso.Espresso.onView;
|
||||
import static com.google.android.apps.common.testing.ui.espresso.action.ViewActions.click;
|
||||
import static com.google.android.apps.common.testing.ui.espresso.action.ViewActions.longClick;
|
||||
import static com.google.android.apps.common.testing.ui.espresso.action.ViewActions.scrollTo;
|
||||
import static com.google.android.apps.common.testing.ui.espresso.assertion.ViewAssertions.doesNotExist;
|
||||
import static com.google.android.apps.common.testing.ui.espresso.assertion.ViewAssertions.matches;
|
||||
import static com.google.android.apps.common.testing.ui.espresso.matcher.ViewMatchers.isDisplayed;
|
||||
import static com.google.android.apps.common.testing.ui.espresso.matcher.ViewMatchers.withId;
|
||||
import static com.google.android.apps.common.testing.ui.espresso.matcher.ViewMatchers.withText;
|
||||
|
||||
public class AccountsPage extends AbstractPage {
|
||||
|
||||
private void assertAccount(String accountDisplayName, boolean exists) {
|
||||
ViewAssertion assertion = exists ? matches(isDisplayed()) : doesNotExist();
|
||||
onView(withText(accountDisplayName)).check(assertion);
|
||||
}
|
||||
|
||||
public AccountSetupPage clickAddNewAccount() {
|
||||
// need to click twice for some reason?
|
||||
onView(withId(R.id.add_new_account)).perform(click());
|
||||
try {
|
||||
onView(withId(R.id.add_new_account)).perform(click());
|
||||
} catch (NoMatchingViewException ex) {
|
||||
// Ignore
|
||||
}
|
||||
onView(withId(R.id.account_email)).perform(scrollTo());
|
||||
return new AccountSetupPage();
|
||||
}
|
||||
|
||||
public void assertAccountExists(String accountDisplayName) {
|
||||
assertAccount(accountDisplayName, true);
|
||||
}
|
||||
|
||||
public void assertAccountDoesNotExist(String accountDisplayName) {
|
||||
assertAccount(accountDisplayName, false);
|
||||
}
|
||||
|
||||
public void clickLongOnAccount(AccountForTest accountForTest) {
|
||||
onView(withText(accountForTest.description)).perform(longClick());
|
||||
}
|
||||
|
||||
public void clickRemoveInAccountMenu() {
|
||||
onView(withText("Remove account")).perform(click());
|
||||
}
|
||||
|
||||
public void clickOK() {
|
||||
onView(withText("OK")).perform(click());
|
||||
}
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
package com.fsck.k9.endtoend.pages;
|
||||
|
||||
import com.fsck.k9.R;
|
||||
import com.fsck.k9.mail.ConnectionSecurity;
|
||||
|
||||
import static com.google.android.apps.common.testing.ui.espresso.Espresso.onData;
|
||||
import static com.google.android.apps.common.testing.ui.espresso.Espresso.onView;
|
||||
import static com.google.android.apps.common.testing.ui.espresso.action.ViewActions.clearText;
|
||||
import static com.google.android.apps.common.testing.ui.espresso.action.ViewActions.click;
|
||||
import static com.google.android.apps.common.testing.ui.espresso.action.ViewActions.scrollTo;
|
||||
import static com.google.android.apps.common.testing.ui.espresso.action.ViewActions.typeText;
|
||||
import static com.google.android.apps.common.testing.ui.espresso.assertion.ViewAssertions.matches;
|
||||
import static com.google.android.apps.common.testing.ui.espresso.matcher.ViewMatchers.isClickable;
|
||||
import static com.google.android.apps.common.testing.ui.espresso.matcher.ViewMatchers.withId;
|
||||
import static com.google.android.apps.common.testing.ui.espresso.matcher.ViewMatchers.withText;
|
||||
import static org.hamcrest.Matchers.allOf;
|
||||
import static org.hamcrest.Matchers.instanceOf;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
|
||||
public class IncomingServerSettingsPage extends AbstractPage {
|
||||
|
||||
public IncomingServerSettingsPage inputImapServer(String imapServer) {
|
||||
onView(withId(R.id.account_server))
|
||||
.perform(scrollTo())
|
||||
.perform(clearText())
|
||||
.perform(typeText(imapServer));
|
||||
return this;
|
||||
}
|
||||
|
||||
public IncomingServerSettingsPage inputImapSecurity(ConnectionSecurity security) {
|
||||
onView(withId(R.id.account_security_type))
|
||||
.perform(scrollTo())
|
||||
.perform(click());
|
||||
onData(allOf(is(instanceOf(ConnectionSecurity.class)), is(security))).perform(click());
|
||||
return this;
|
||||
}
|
||||
|
||||
public IncomingServerSettingsPage inputPort(int port) {
|
||||
onView(withId(R.id.account_port))
|
||||
.perform(scrollTo())
|
||||
.perform(clearText())
|
||||
.perform(typeText(String.valueOf(port)));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public OutgoingServerSettingsPage clickNext() {
|
||||
onView(withId(R.id.next))
|
||||
// .perform(scrollTo())
|
||||
.check(matches(isClickable()))
|
||||
.perform(click());
|
||||
|
||||
// We know this view is on the next page, this functions as a wait.
|
||||
onView(withText("SMTP server")).perform(scrollTo());
|
||||
return new OutgoingServerSettingsPage();
|
||||
}
|
||||
|
||||
public IncomingServerSettingsPage inputUsername(String loginUsername) {
|
||||
onView(withId(R.id.account_username))
|
||||
.perform(scrollTo())
|
||||
.perform(clearText())
|
||||
.perform(typeText(loginUsername));
|
||||
return this;
|
||||
|