コード例 #1
0
  @Test
  public void testMarketLaunch() {
    ShadowActivity shadowActivity = Robolectric.shadowOf(helloAndroidActivity);
    helloAndroidActivity.launchMarket();
    Intent startedIntent = shadowActivity.getNextStartedActivity();

    Uri marketUri = Uri.parse("market://details?id=com.example");
    assertEquals(marketUri, startedIntent.getData());
  }
コード例 #2
0
 @Test
 public void testText() {
   TextView textView = (TextView) helloAndroidActivity.findViewById(R.id.text);
   assertEquals("*** Hello World ***", textView.getText());
 }
コード例 #3
0
 @Test
 public void testImage() {
   ImageView imageView = (ImageView) helloAndroidActivity.findViewById(R.id.image);
   ShadowImageView shadowImageView = Robolectric.shadowOf(imageView);
   assertEquals(R.drawable.robo, shadowImageView.getResourceId());
 }
コード例 #4
0
 @Before
 public void setUp() {
   helloAndroidActivity = new HelloActivity();
   helloAndroidActivity.onCreate(null);
 }