use of io.reactivex.observers.TestObserver in project RxPermissions by tbruyelle.
the class RxPermissionsTest method eachSubscription_preM.
@Test
@TargetApi(Build.VERSION_CODES.M)
public void eachSubscription_preM() {
TestObserver<Permission> sub = new TestObserver<>();
String permission = Manifest.permission.READ_PHONE_STATE;
when(mRxPermissions.isGranted(permission)).thenReturn(true);
trigger().compose(mRxPermissions.ensureEach(permission)).subscribe(sub);
sub.assertNoErrors();
sub.assertTerminated();
sub.assertValue(new Permission(permission, true));
}
use of io.reactivex.observers.TestObserver in project RxPermissions by tbruyelle.
the class RxPermissionsTest method shouldShowRequestPermissionRationale_oneDeniedNotRationale.
@Test
@TargetApi(Build.VERSION_CODES.M)
public void shouldShowRequestPermissionRationale_oneDeniedNotRationale() {
when(mRxPermissions.isMarshmallow()).thenReturn(true);
Activity activity = mock(Activity.class);
when(mRxPermissions.isGranted("p2")).thenReturn(true);
TestObserver<Boolean> sub = new TestObserver<>();
mRxPermissions.shouldShowRequestPermissionRationale(activity, new String[] { "p1", "p2" }).subscribe(sub);
sub.assertComplete();
sub.assertNoErrors();
sub.assertValue(false);
}
use of io.reactivex.observers.TestObserver in project RxPermissions by tbruyelle.
the class RxPermissionsTest method shouldShowRequestPermissionRationale_oneDeniedRationale.
@Test
@TargetApi(Build.VERSION_CODES.M)
public void shouldShowRequestPermissionRationale_oneDeniedRationale() {
when(mRxPermissions.isMarshmallow()).thenReturn(true);
Activity activity = mock(Activity.class);
when(mRxPermissions.isGranted("p1")).thenReturn(true);
when(activity.shouldShowRequestPermissionRationale("p2")).thenReturn(true);
TestObserver<Boolean> sub = new TestObserver<>();
mRxPermissions.shouldShowRequestPermissionRationale(activity, new String[] { "p1", "p2" }).subscribe(sub);
sub.assertComplete();
sub.assertNoErrors();
sub.assertValue(true);
}
use of io.reactivex.observers.TestObserver in project RxPermissions by tbruyelle.
the class RxPermissionsTest method eachSubscription_revoked.
@Test
@TargetApi(Build.VERSION_CODES.M)
public void eachSubscription_revoked() {
TestObserver<Permission> sub = new TestObserver<>();
String permission = Manifest.permission.READ_PHONE_STATE;
when(mRxPermissions.isRevoked(permission)).thenReturn(true);
trigger().compose(mRxPermissions.ensureEach(permission)).subscribe(sub);
sub.assertNoErrors();
sub.assertTerminated();
sub.assertValue(new Permission(permission, false));
}
use of io.reactivex.observers.TestObserver in project RxPermissions by tbruyelle.
the class RxPermissionsTest method shouldShowRequestPermissionRationale_allDenied_allRationale.
@Test
@TargetApi(Build.VERSION_CODES.M)
public void shouldShowRequestPermissionRationale_allDenied_allRationale() {
when(mRxPermissions.isMarshmallow()).thenReturn(true);
Activity activity = mock(Activity.class);
when(activity.shouldShowRequestPermissionRationale(anyString())).thenReturn(true);
TestObserver<Boolean> sub = new TestObserver<>();
mRxPermissions.shouldShowRequestPermissionRationale(activity, new String[] { "p1", "p2" }).subscribe(sub);
sub.assertComplete();
sub.assertNoErrors();
sub.assertValue(true);
}
Aggregations