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


Java ShadowAccountManager类代码示例

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


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

示例1: testExistingAccount

import org.robolectric.shadows.ShadowAccountManager; //导入依赖的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

示例2: testAddAccount

import org.robolectric.shadows.ShadowAccountManager; //导入依赖的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

示例3: setUp

import org.robolectric.shadows.ShadowAccountManager; //导入依赖的package包/类
@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    call = mock(Call.class);
    Call.Factory callFactory = mock(Call.Factory.class);
    when(callFactory.newCall(any(Request.class))).thenReturn(call);
    userServices = new UserServicesClient(callFactory, Schedulers.immediate());
    Preferences.setUsername(RuntimeEnvironment.application, "username");
    account = new Account("username", BuildConfig.APPLICATION_ID);
    ShadowAccountManager.get(RuntimeEnvironment.application)
            .addAccountExplicitly(account, "password", null);
}
 
开发者ID:hidroh,项目名称:materialistic,代码行数:13,代码来源:UserServicesClientTest.java

示例4: testVoteNoAccount

import org.robolectric.shadows.ShadowAccountManager; //导入依赖的package包/类
@Test
public void testVoteNoAccount() throws IOException {
    ShadowAccountManager.get(RuntimeEnvironment.application)
            .removeAccount(account, null, null);
    UserServices.Callback callback = mock(UserServices.Callback.class);
    assertFalse(userServices.voteUp(RuntimeEnvironment.application, "1", callback));
    verify(call, never()).enqueue(any(Callback.class));
}
 
开发者ID:hidroh,项目名称:materialistic,代码行数:9,代码来源:UserServicesClientTest.java

示例5: testSubmitNoAccount

import org.robolectric.shadows.ShadowAccountManager; //导入依赖的package包/类
@Test
public void testSubmitNoAccount() throws IOException {
    ShadowAccountManager.get(RuntimeEnvironment.application)
            .removeAccount(account, null, null);
    UserServices.Callback callback = mock(UserServices.Callback.class);
    userServices.submit(RuntimeEnvironment.application, "title", "content", true, callback);
    verify(call, never()).enqueue(any(Callback.class));
    verify(callback).onDone(eq(false));
}
 
开发者ID:hidroh,项目名称:materialistic,代码行数:10,代码来源:UserServicesClientTest.java

示例6: testRemoveAccount

import org.robolectric.shadows.ShadowAccountManager; //导入依赖的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

示例7: testLoginStaleAccount

import org.robolectric.shadows.ShadowAccountManager; //导入依赖的package包/类
@Test
public void testLoginStaleAccount() {
    Preferences.setUsername(RuntimeEnvironment.application, "username");
    shadowOf(ShadowAccountManager.get(RuntimeEnvironment.application))
            .addAccount(new Account("username", BuildConfig.APPLICATION_ID));
    AppUtils.showLogin(RuntimeEnvironment.application, null);
    assertThat(shadowOf(RuntimeEnvironment.application).getNextStartedActivity())
            .hasComponent(RuntimeEnvironment.application, LoginActivity.class);
}
 
开发者ID:hidroh,项目名称:materialistic,代码行数:10,代码来源:AppUtilsTest.java

示例8: testLoginShowChooser

import org.robolectric.shadows.ShadowAccountManager; //导入依赖的package包/类
@Test
public void testLoginShowChooser() {
    TestApplication.applicationGraph.inject(this);
    shadowOf(ShadowAccountManager.get(RuntimeEnvironment.application))
            .addAccount(new Account("username", BuildConfig.APPLICATION_ID));
    AppUtils.showLogin(RuntimeEnvironment.application, alertDialogBuilder);
    assertNotNull(ShadowAlertDialog.getLatestAlertDialog());
}
 
开发者ID:hidroh,项目名称:materialistic,代码行数:9,代码来源:AppUtilsTest.java

示例9: testLoginSuccessful

import org.robolectric.shadows.ShadowAccountManager; //导入依赖的package包/类
@Test
public void testLoginSuccessful() {
    ((EditText) activity.findViewById(R.id.edittext_username)).setText("username");
    ((EditText) activity.findViewById(R.id.edittext_password)).setText("password");
    activity.findViewById(R.id.login_button).performClick();
    assertNull(((TextInputLayout) activity.findViewById(R.id.textinput_username)).getError());
    assertNull(((TextInputLayout) activity.findViewById(R.id.textinput_password)).getError());
    verify(userServices).login(eq("username"), eq("password"), eq(false), callback.capture());
    callback.getValue().onDone(true);
    assertThat(activity).isFinishing();
    assertEquals(activity.getString(R.string.welcome, "username"), ShadowToast.getTextOfLatestToast());
    assertThat(ShadowAccountManager.get(activity).getAccounts()).hasSize(1);
    assertEquals("username", Preferences.getUsername(activity));
}
 
开发者ID:hidroh,项目名称:materialistic,代码行数:15,代码来源:LoginActivityTest.java

示例10: provideAccountManager

import org.robolectric.shadows.ShadowAccountManager; //导入依赖的package包/类
@Provides
public AccountManager provideAccountManager() {
    return ShadowAccountManager.get(RuntimeEnvironment.application);
}
 
开发者ID:hidroh,项目名称:materialistic,代码行数:5,代码来源:TestActivityModule.java

示例11: shadowOf

import org.robolectric.shadows.ShadowAccountManager; //导入依赖的package包/类
public static ShadowAccountManager shadowOf(AccountManager instance) {
  return (ShadowAccountManager) shadowOf_(instance);
}
 
开发者ID:qx,项目名称:FullRobolectricTestSample,代码行数:4,代码来源:Robolectric.java


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