Search in sources :

Example 96 with EditText

use of android.widget.EditText in project materialistic by hidroh.

the class ComposeActivityTest method testExitSaveDraft.

@Test
public void testExitSaveDraft() {
    ((EditText) activity.findViewById(R.id.edittext_body)).setText("Reply");
    shadowOf(activity).clickMenuItem(android.R.id.home);
    AlertDialog alertDialog = ShadowAlertDialog.getLatestAlertDialog();
    assertNotNull(alertDialog);
    alertDialog.getButton(DialogInterface.BUTTON_POSITIVE).performClick();
    assertThat(activity).isFinishing();
    assertThat(Preferences.getDraft(activity, "1")).contains("Reply");
}
Also used : EditText(android.widget.EditText) ShadowAlertDialog(org.robolectric.shadows.ShadowAlertDialog) AlertDialog(android.app.AlertDialog) Test(org.junit.Test)

Example 97 with EditText

use of android.widget.EditText in project materialistic by hidroh.

the class ComposeActivityTest method testExitDiscardDraft.

@Test
public void testExitDiscardDraft() {
    ((EditText) activity.findViewById(R.id.edittext_body)).setText("Reply");
    shadowOf(activity).clickMenuItem(android.R.id.home);
    AlertDialog alertDialog = ShadowAlertDialog.getLatestAlertDialog();
    assertNotNull(alertDialog);
    alertDialog.getButton(DialogInterface.BUTTON_NEGATIVE).performClick();
    assertThat(activity).isFinishing();
    assertThat(Preferences.getDraft(activity, "1")).isNullOrEmpty();
}
Also used : EditText(android.widget.EditText) ShadowAlertDialog(org.robolectric.shadows.ShadowAlertDialog) AlertDialog(android.app.AlertDialog) Test(org.junit.Test)

Example 98 with EditText

use of android.widget.EditText in project materialistic by hidroh.

the class SubmitActivityTest method testSubmitText.

@Test
public void testSubmitText() {
    ((EditText) activity.findViewById(R.id.edittext_title)).setText("title");
    ((EditText) activity.findViewById(R.id.edittext_content)).setText("content");
    shadowOf(activity).clickMenuItem(R.id.menu_send);
    AlertDialog alertDialog = ShadowAlertDialog.getLatestAlertDialog();
    assertNotNull(alertDialog);
    assertEquals(activity.getString(R.string.confirm_submit_question), shadowOf(alertDialog).getMessage());
}
Also used : EditText(android.widget.EditText) ShadowAlertDialog(org.robolectric.shadows.ShadowAlertDialog) AlertDialog(android.app.AlertDialog) Test(org.junit.Test)

Example 99 with EditText

use of android.widget.EditText in project materialistic by hidroh.

the class SubmitActivityTest method testSubmitUrl.

@Test
public void testSubmitUrl() {
    ((EditText) activity.findViewById(R.id.edittext_title)).setText("title");
    ((EditText) activity.findViewById(R.id.edittext_content)).setText("http://example.com");
    shadowOf(activity).clickMenuItem(R.id.menu_send);
    AlertDialog alertDialog = ShadowAlertDialog.getLatestAlertDialog();
    assertNotNull(alertDialog);
    assertEquals(activity.getString(R.string.confirm_submit_url), shadowOf(alertDialog).getMessage());
}
Also used : EditText(android.widget.EditText) ShadowAlertDialog(org.robolectric.shadows.ShadowAlertDialog) AlertDialog(android.app.AlertDialog) Test(org.junit.Test)

Example 100 with EditText

use of android.widget.EditText in project materialistic by hidroh.

the class SubmitActivityTest method testSubmitDelayedError.

@Test
public void testSubmitDelayedError() {
    ((EditText) activity.findViewById(R.id.edittext_title)).setText("title");
    ((EditText) activity.findViewById(R.id.edittext_content)).setText("http://example.com");
    shadowOf(activity).clickMenuItem(R.id.menu_send);
    ShadowAlertDialog.getLatestAlertDialog().getButton(DialogInterface.BUTTON_POSITIVE).performClick();
    verify(userServices).submit(any(Context.class), eq("title"), eq("http://example.com"), eq(true), submitCallback.capture());
    shadowOf(activity).clickMenuItem(android.R.id.home);
    ShadowAlertDialog.getLatestAlertDialog().getButton(DialogInterface.BUTTON_POSITIVE).performClick();
    submitCallback.getValue().onError(new IOException());
    assertEquals(activity.getString(R.string.submit_failed), ShadowToast.getTextOfLatestToast());
}
Also used : EditText(android.widget.EditText) Context(android.content.Context) IOException(java.io.IOException) Test(org.junit.Test)

Aggregations

EditText (android.widget.EditText)655 View (android.view.View)309 TextView (android.widget.TextView)220 DialogInterface (android.content.DialogInterface)143 AlertDialog (android.app.AlertDialog)126 Button (android.widget.Button)126 Intent (android.content.Intent)99 LinearLayout (android.widget.LinearLayout)79 ImageView (android.widget.ImageView)61 AlertDialog (android.support.v7.app.AlertDialog)54 ScrollView (android.widget.ScrollView)52 LayoutInflater (android.view.LayoutInflater)48 AdapterView (android.widget.AdapterView)46 ViewGroup (android.view.ViewGroup)42 Editable (android.text.Editable)41 Context (android.content.Context)40 RecyclerView (android.support.v7.widget.RecyclerView)40 ListView (android.widget.ListView)39 Dialog (android.app.Dialog)36 Bundle (android.os.Bundle)36