本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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));
}
示例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));
}
示例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();
}
示例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);
}
示例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());
}
示例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));
}
示例10: provideAccountManager
import org.robolectric.shadows.ShadowAccountManager; //导入依赖的package包/类
@Provides
public AccountManager provideAccountManager() {
return ShadowAccountManager.get(RuntimeEnvironment.application);
}
示例11: shadowOf
import org.robolectric.shadows.ShadowAccountManager; //导入依赖的package包/类
public static ShadowAccountManager shadowOf(AccountManager instance) {
return (ShadowAccountManager) shadowOf_(instance);
}