当前位置: 首页>>代码示例>>Java>>正文


Java ShadowAlertDialog.getLatestAlertDialog方法代码示例

本文整理汇总了Java中org.robolectric.shadows.ShadowAlertDialog.getLatestAlertDialog方法的典型用法代码示例。如果您正苦于以下问题:Java ShadowAlertDialog.getLatestAlertDialog方法的具体用法?Java ShadowAlertDialog.getLatestAlertDialog怎么用?Java ShadowAlertDialog.getLatestAlertDialog使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.robolectric.shadows.ShadowAlertDialog的用法示例。


在下文中一共展示了ShadowAlertDialog.getLatestAlertDialog方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testOptionsMenuClear

import org.robolectric.shadows.ShadowAlertDialog; //导入方法依赖的package包/类
@Test
public void testOptionsMenuClear() {
    assertTrue(shadowOf(activity).getOptionsMenu().findItem(R.id.menu_clear).isVisible());
    shadowOf(activity).clickMenuItem(R.id.menu_clear);
    AlertDialog dialog = ShadowAlertDialog.getLatestAlertDialog();
    dialog.getButton(DialogInterface.BUTTON_NEGATIVE).performClick();
    assertEquals(2, adapter.getItemCount());

    shadowOf(activity).clickMenuItem(R.id.menu_clear);
    dialog = ShadowAlertDialog.getLatestAlertDialog();
    dialog.getButton(DialogInterface.BUTTON_POSITIVE).performClick();
    verify(favoriteManager).clear(any(Context.class), any());
    when(favoriteManager.getSize()).thenReturn(0);
    observerCaptor.getValue().onChanged();
    assertEquals(0, adapter.getItemCount());
}
 
开发者ID:hidroh,项目名称:materialistic,代码行数:17,代码来源:FavoriteActivityTest.java

示例2: testDelete

import org.robolectric.shadows.ShadowAlertDialog; //导入方法依赖的package包/类
@Test
public void testDelete() {
    RecyclerView.ViewHolder holder = shadowAdapter.getViewHolder(0);
    holder.itemView.performLongClick();

    ActionMode actionMode = mock(ActionMode.class);
    activity.actionModeCallback.onActionItemClicked(actionMode, new RoboMenuItem(R.id.menu_clear));
    AlertDialog dialog = ShadowAlertDialog.getLatestAlertDialog();
    dialog.getButton(DialogInterface.BUTTON_NEGATIVE).performClick();
    assertEquals(2, adapter.getItemCount());

    activity.actionModeCallback.onActionItemClicked(actionMode, new RoboMenuItem(R.id.menu_clear));
    dialog = ShadowAlertDialog.getLatestAlertDialog();
    dialog.getButton(DialogInterface.BUTTON_POSITIVE).performClick();
    verify(favoriteManager).remove(any(Context.class), selection.capture());
    assertThat(selection.getValue()).contains("1");
    verify(actionMode).finish();

    when(favoriteManager.getSize()).thenReturn(1);
    observerCaptor.getValue().onChanged();
    assertEquals(1, adapter.getItemCount());
}
 
开发者ID:hidroh,项目名称:materialistic,代码行数:23,代码来源:FavoriteActivityTest.java

示例3: testNoExistingAccount

import org.robolectric.shadows.ShadowAlertDialog; //导入方法依赖的package包/类
@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();
}
 
开发者ID:hidroh,项目名称:materialistic,代码行数:17,代码来源:DrawerActivityLoginTest.java

示例4: testExistingAccount

import org.robolectric.shadows.ShadowAlertDialog; //导入方法依赖的package包/类
@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);
}
 
开发者ID:hidroh,项目名称:materialistic,代码行数:18,代码来源:DrawerActivityLoginTest.java

示例5: testAddAccount

import org.robolectric.shadows.ShadowAlertDialog; //导入方法依赖的package包/类
@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);
}
 
开发者ID:hidroh,项目名称:materialistic,代码行数:17,代码来源:DrawerActivityLoginTest.java

示例6: whenLocationIsDisabledItShouldShowError

import org.robolectric.shadows.ShadowAlertDialog; //导入方法依赖的package包/类
@Test
public void whenLocationIsDisabledItShouldShowError() throws Exception {
    // given
    shadowLocationManager.setProviderEnabled(LocationManager.GPS_PROVIDER, false);
    shadowLocationManager.setProviderEnabled(LocationManager.NETWORK_PROVIDER, false);
    welcomeActivity = Robolectric.setupActivity(WelcomeActivity.class);

    String expectedMessage = welcomeActivity.getString(R.string.message_error_location);

    // when
    welcomeActivity.onResume();

    AlertDialog dialog = ShadowAlertDialog.getLatestAlertDialog();
    ShadowAlertDialog shadowAlertDialog = shadowOf(dialog);

    // then
    assertEquals(expectedMessage, shadowAlertDialog.getMessage().toString());
}
 
开发者ID:cristianoliveira,项目名称:bikeon-android-app,代码行数:19,代码来源:WelcomeActivityTest.java

示例7: showUserDownloadImageAlert_withActivityContext_shouldDisplayAlertDialog

import org.robolectric.shadows.ShadowAlertDialog; //导入方法依赖的package包/类
@Ignore("Mraid 2.0")
@Test
public void showUserDownloadImageAlert_withActivityContext_shouldDisplayAlertDialog() throws Exception {
    response = new TestHttpResponseWithHeaders(200, FAKE_IMAGE_DATA);

    subject.storePicture(context, IMAGE_URI_VALUE, mraidCommandFailureListener);

    AlertDialog alertDialog = ShadowAlertDialog.getLatestAlertDialog();
    ShadowAlertDialog shadowAlertDialog = shadowOf(alertDialog);

    assertThat(alertDialog.isShowing());

    assertThat(shadowAlertDialog.getTitle()).isEqualTo("Save Image");
    assertThat(shadowAlertDialog.getMessage()).isEqualTo("Download image to Picture gallery?");
    assertThat(shadowAlertDialog.isCancelable()).isTrue();

    assertThat(alertDialog.getButton(BUTTON_POSITIVE).hasOnClickListeners());
    assertThat(alertDialog.getButton(BUTTON_NEGATIVE)).isNotNull();
}
 
开发者ID:JSafaiyeh,项目名称:Fabric-Example-App-Android,代码行数:20,代码来源:MraidNativeCommandHandlerTest.java

示例8: textExternalWithoutPermission

import org.robolectric.shadows.ShadowAlertDialog; //导入方法依赖的package包/类
@Test
public void textExternalWithoutPermission() {

    Intent intent = new Intent(AppConfig.FLOW_ACTION_CADDISFLY);

    Bundle data = new Bundle();
    data.putString(CADDISFLY_RESOURCE_ID, Constants.FLUORIDE_ID);
    data.putString(CADDISFLY_QUESTION_ID, "123");
    data.putString(CADDISFLY_QUESTION_TITLE, "Fluoride");
    data.putString(CADDISFLY_LANGUAGE, "en");

    intent.putExtras(data);
    intent.setType("text/plain");

    ActivityController controller = Robolectric.buildActivity(TestActivity.class, intent).create();

    controller.start();

    AlertDialog alert = ShadowAlertDialog.getLatestAlertDialog();
    ShadowAlertDialog sAlert = shadowOf(alert);

    assertEquals(sAlert.getMessage(), "Calibration for Water - Fluoride is incomplete\n" +
            "\n" +
            "Do you want to calibrate now?");

}
 
开发者ID:akvo,项目名称:akvo-caddisfly,代码行数:27,代码来源:ChamberTest.java

示例9: tapRefreshShowsAlertWhenInternetNotPresent

import org.robolectric.shadows.ShadowAlertDialog; //导入方法依赖的package包/类
@Test
public void tapRefreshShowsAlertWhenInternetNotPresent()
{
    when(reachability.isNetworkConnected()).thenReturn(false);

    button.performClick();
    AlertDialog alert = ShadowAlertDialog.getLatestAlertDialog();
    ShadowAlertDialog sAlert = shadowOf(alert);

    assertThat(sAlert.getTitle().toString(),
            equalTo(activity.getString(R.string.error)));
    assertThat(sAlert.getMessage().toString(),
            equalTo(activity.getString(R.string.couldnt_connect_error)));
}
 
开发者ID:ello,项目名称:ello-android,代码行数:15,代码来源:NoInternetActivityTest.java

示例10: testRemoveAccount

import org.robolectric.shadows.ShadowAlertDialog; //导入方法依赖的package包/类
@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();
}
 
开发者ID:hidroh,项目名称:materialistic,代码行数:15,代码来源:DrawerActivityLoginTest.java

示例11: testOnBackPressed

import org.robolectric.shadows.ShadowAlertDialog; //导入方法依赖的package包/类
@Test
public void testOnBackPressed() {
    shadowOf(activity).clickMenuItem(android.R.id.home);
    AlertDialog alertDialog = ShadowAlertDialog.getLatestAlertDialog();
    assertNotNull(alertDialog);
    alertDialog.getButton(DialogInterface.BUTTON_POSITIVE).performClick();
    assertThat(activity).isFinishing();
}
 
开发者ID:hidroh,项目名称:materialistic,代码行数:9,代码来源:SubmitActivityTest.java

示例12: testSubmitUrl

import org.robolectric.shadows.ShadowAlertDialog; //导入方法依赖的package包/类
@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());
}
 
开发者ID:hidroh,项目名称:materialistic,代码行数:11,代码来源:SubmitActivityTest.java

示例13: testExitSaveDraft

import org.robolectric.shadows.ShadowAlertDialog; //导入方法依赖的package包/类
@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");
}
 
开发者ID:hidroh,项目名称:materialistic,代码行数:11,代码来源:ComposeActivityTest.java

示例14: testExitDiscardDraft

import org.robolectric.shadows.ShadowAlertDialog; //导入方法依赖的package包/类
@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();
}
 
开发者ID:hidroh,项目名称:materialistic,代码行数:11,代码来源:ComposeActivityTest.java

示例15: testClearRecentSearches

import org.robolectric.shadows.ShadowAlertDialog; //导入方法依赖的package包/类
@Test
public void testClearRecentSearches() {
    ShadowSearchRecentSuggestions.historyClearCount = 0;
    assertNotNull(shadowOf(activity).getOptionsMenu().findItem(R.id.menu_clear_recent));
    shadowOf(activity).clickMenuItem(R.id.menu_clear_recent);
    AlertDialog alertDialog = ShadowAlertDialog.getLatestAlertDialog();
    assertNotNull(alertDialog);
    alertDialog.getButton(DialogInterface.BUTTON_POSITIVE).performClick();
    assertEquals(1, ShadowSearchRecentSuggestions.historyClearCount);
}
 
开发者ID:hidroh,项目名称:materialistic,代码行数:11,代码来源:SettingsActivityTest.java


注:本文中的org.robolectric.shadows.ShadowAlertDialog.getLatestAlertDialog方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。