Search in sources :

Example 1 with AlertDialog

use of android.app.AlertDialog in project cw-omnibus by commonsguy.

the class ConstantsFragment method onClick.

public void onClick(DialogInterface di, int whichButton) {
    ContentValues values = new ContentValues(2);
    AlertDialog dlg = (AlertDialog) di;
    EditText title = (EditText) dlg.findViewById(R.id.title);
    EditText value = (EditText) dlg.findViewById(R.id.value);
    values.put(DatabaseHelper.TITLE, title.getText().toString());
    values.put(DatabaseHelper.VALUE, value.getText().toString());
    task = new InsertTask().execute(values);
}
Also used : ContentValues(android.content.ContentValues) AlertDialog(android.app.AlertDialog) EditText(android.widget.EditText)

Example 2 with AlertDialog

use of android.app.AlertDialog in project materialistic by hidroh.

the class DrawerActivityLoginTest method testNoExistingAccount.

@Test
public void testNoExistingAccount() {
    assertThat(drawerAccount).hasText(R.string.login);
    assertThat(drawerLogout).isNotVisible();
    assertThat(drawerUser).isNotVisible();
    Preferences.setUsername(activity, "username");
    assertThat(drawerAccount).hasText("username");
    assertThat(drawerLogout).isVisible();
    assertThat(drawerUser).isVisible();
    drawerLogout.performClick();
    AlertDialog alertDialog = ShadowAlertDialog.getLatestAlertDialog();
    assertNotNull(alertDialog);
    alertDialog.getButton(DialogInterface.BUTTON_POSITIVE).performClick();
    assertThat(drawerAccount).hasText(R.string.login);
    assertThat(drawerLogout).isNotVisible();
}
Also used : AlertDialog(android.app.AlertDialog) ShadowAlertDialog(org.robolectric.shadows.ShadowAlertDialog) Test(org.junit.Test)

Example 3 with AlertDialog

use of android.app.AlertDialog in project materialistic by hidroh.

the class DrawerActivityLoginTest method testRemoveAccount.

@Config(sdk = 21)
@Test
public void testRemoveAccount() {
    ShadowAccountManager.get(activity).addAccountExplicitly(new Account("existing", BuildConfig.APPLICATION_ID), "password", null);
    Preferences.setUsername(activity, "existing");
    drawerAccount.performClick();
    AlertDialog alertDialog = ShadowAlertDialog.getLatestAlertDialog();
    assertNotNull(alertDialog);
    assertThat(alertDialog.getListView().getAdapter()).hasCount(1);
    alertDialog.getButton(DialogInterface.BUTTON_NEUTRAL).performClick();
    assertThat(alertDialog).isNotShowing();
    assertThat(ShadowAccountManager.get(activity).getAccounts()).isEmpty();
}
Also used : AlertDialog(android.app.AlertDialog) ShadowAlertDialog(org.robolectric.shadows.ShadowAlertDialog) Account(android.accounts.Account) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 4 with AlertDialog

use of android.app.AlertDialog in project materialistic by hidroh.

the class DrawerActivityLoginTest method testExistingAccount.

@Test
public void testExistingAccount() {
    ShadowAccountManager.get(activity).addAccountExplicitly(new Account("existing", BuildConfig.APPLICATION_ID), "password", null);
    drawerAccount.performClick();
    AlertDialog alertDialog = ShadowAlertDialog.getLatestAlertDialog();
    assertNotNull(alertDialog);
    assertThat(alertDialog.getListView().getAdapter()).hasCount(1);
    shadowOf(alertDialog).clickOnItem(0);
    alertDialog.getButton(DialogInterface.BUTTON_POSITIVE).performClick();
    assertThat(alertDialog).isNotShowing();
    assertThat(drawerAccount).hasText("existing");
    assertThat(drawerLogout).isVisible();
    drawerAccount.performClick();
    alertDialog = ShadowAlertDialog.getLatestAlertDialog();
    assertThat(alertDialog.getListView().getAdapter()).hasCount(1);
}
Also used : AlertDialog(android.app.AlertDialog) ShadowAlertDialog(org.robolectric.shadows.ShadowAlertDialog) Account(android.accounts.Account) Test(org.junit.Test)

Example 5 with AlertDialog

use of android.app.AlertDialog in project materialistic by hidroh.

the class DrawerActivityLoginTest method testAddAccount.

@Test
public void testAddAccount() {
    ShadowAccountManager.get(activity).addAccountExplicitly(new Account("existing", BuildConfig.APPLICATION_ID), "password", null);
    drawerAccount.performClick();
    AlertDialog alertDialog = ShadowAlertDialog.getLatestAlertDialog();
    assertNotNull(alertDialog);
    assertThat(alertDialog.getListView().getAdapter()).hasCount(1);
    alertDialog.getButton(DialogInterface.BUTTON_NEGATIVE).performClick();
    assertThat(alertDialog).isNotShowing();
    ((ShadowSupportDrawerLayout) ShadowExtractor.extract(activity.findViewById(R.id.drawer_layout))).getDrawerListeners().get(0).onDrawerClosed(activity.findViewById(R.id.drawer));
    assertThat(shadowOf(activity).getNextStartedActivity()).hasComponent(activity, LoginActivity.class);
}
Also used : AlertDialog(android.app.AlertDialog) ShadowAlertDialog(org.robolectric.shadows.ShadowAlertDialog) ShadowSupportDrawerLayout(io.github.hidroh.materialistic.test.shadow.ShadowSupportDrawerLayout) Account(android.accounts.Account) Test(org.junit.Test)

Aggregations

AlertDialog (android.app.AlertDialog)1029 DialogInterface (android.content.DialogInterface)573 View (android.view.View)278 TextView (android.widget.TextView)213 Intent (android.content.Intent)172 EditText (android.widget.EditText)160 Test (org.junit.Test)148 ShadowAlertDialog (org.robolectric.shadows.ShadowAlertDialog)111 Context (android.content.Context)96 ListView (android.widget.ListView)87 ImageView (android.widget.ImageView)86 LayoutInflater (android.view.LayoutInflater)80 Button (android.widget.Button)78 AdapterView (android.widget.AdapterView)72 Activity (android.app.Activity)66 SuppressLint (android.annotation.SuppressLint)61 Bundle (android.os.Bundle)56 OnClickListener (android.content.DialogInterface.OnClickListener)54 ArrayList (java.util.ArrayList)50 Dialog (android.app.Dialog)46