Skip to content

Instantly share code, notes, and snippets.

@shikajiro
Created August 13, 2014 16:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shikajiro/5f26c021fc00e7b22992 to your computer and use it in GitHub Desktop.
Save shikajiro/5f26c021fc00e7b22992 to your computer and use it in GitHub Desktop.
Androidでのテストで色々悩んだ結果robotiumになった件 ref: http://qiita.com/shikajiro@github/items/d28bf5eb4c9268f81131
public void testSayHello() {
//このclickで画面遷移すると仮定する。
onView(withId(R.id.greet_button))
.perform(click());
//遷移後の画面に"Hello Steve!"が表示されるが、このassertはOKだったりNGだったりする。
onView(withText("Hello Steve!"))
.check(matches(isDisplayed()));
}
buildTypes {
debug{
applicationIdSuffix ".debug"
}
}
//クリックすると非同期処理が始まる
clickOn(view);
//ちょっとまってくれる(願望)
Robolectric.runUiThreadTasksIncludingDelayedTasks()
//非同期処理終了後、ダイアログが表示されるはずなので取得する。
AlertDialog alert = ShadowAlertDialog.getLatestAlertDialog();
//だが、この時点でalertはnull
assertNotNull(alert);
public void testTerm(){
//viewのクリック処理
solo.clickOnView(mActivity.findViewById(R.id.termView));
//新規に開いたActivityと一致するか
solo.assertCurrentActivity("利用規約画面", TermWebActivity_.class);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment