ActivityResult { public static OnResult onResult(final int requestCode, final int resultCode, @Nullable final Intent intent) { return new OnResult(requestCode, resultCode, intent); } private  ActivityResult(); static OnResult onResult(final int requestCode, final int resultCode, @Nullable final Intent intent);  }
@Test public void onActivityResultClassIsNotFound() { final ActivityResult.OnResult onResult = ActivityResult.onResult(0, 0, null); final LonelyObject lonelyObject = new LonelyObject(); expectedException.expect(ActivityResult.ActivityResultRuntimeException.class); expectedException.expectMessage("Could not find OnActivityResult class for onactivityresult.ActivityResultTest$LonelyObject"); onResult.into(lonelyObject); }
@Test public void onActivityResultClassFound() { final ActivityResult.OnResult onResult = ActivityResult.onResult(1, 2, null); final OnResult result = new OnResult(); expectedException.expect(RuntimeException.class); expectedException.expectMessage("OnResult was called: 1, 2, null"); onResult.into(result); }
@Test public void onResultShouldThrowRuntimeExceptionWithPrivateConstructorTextWhenOnActivityResultHasPrivateConstructor() { final ActivityResult.OnResult onResult = ActivityResult.onResult(0, 0, null); final OnResultPrivateObject onResultPrivateObject = new OnResultPrivateObject(); expectedException.expect(ActivityResult.ActivityResultRuntimeException.class); expectedException.expectMessage("Can't create OnActivityResult class for onactivityresult.ActivityResultTest$OnResultPrivateObject"); onResult.into(onResultPrivateObject); }
@Test public void childActivityResultWillLookForParentWhenChildHasNoGeneratedClass() { final ActivityResult.OnResult onResult = ActivityResult.onResult(1, 2, null); final Child child = new Child(); expectedException.expect(RuntimeException.class); expectedException.expectMessage("Extract was called in parent"); onResult.into(child); }
@Test public void returnValueOfResult() { final ActivityResult.OnResult onResult = ActivityResult.onResult(1, 2, null); final Result result = new Result(); assertTrue(onResult.into(result)); }