use of io.reactivex.observers.TestObserver in project RxPermissions by tbruyelle.
the class RxPermissionsTest method eachSubscriptionCombined_denied.
@Test
@TargetApi(Build.VERSION_CODES.M)
public void eachSubscriptionCombined_denied() {
TestObserver<Permission> sub = new TestObserver<>();
String permission = Manifest.permission.READ_PHONE_STATE;
when(mRxPermissions.isGranted(permission)).thenReturn(false);
int[] result = new int[] { PackageManager.PERMISSION_DENIED };
trigger().compose(mRxPermissions.ensureEachCombined(permission)).subscribe(sub);
mRxPermissions.onRequestPermissionsResult(new String[] { permission }, result);
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 subscription_alreadyGranted.
@Test
@TargetApi(Build.VERSION_CODES.M)
public void subscription_alreadyGranted() {
TestObserver<Boolean> sub = new TestObserver<>();
String permission = Manifest.permission.READ_PHONE_STATE;
when(mRxPermissions.isGranted(permission)).thenReturn(true);
trigger().compose(mRxPermissions.ensure(permission)).subscribe(sub);
sub.assertNoErrors();
sub.assertTerminated();
sub.assertValue(true);
}
use of io.reactivex.observers.TestObserver in project RxPermissions by tbruyelle.
the class RxPermissionsTest method shouldShowRequestPermissionRationale_allDenied_noRationale.
@Test
@TargetApi(Build.VERSION_CODES.M)
public void shouldShowRequestPermissionRationale_allDenied_noRationale() {
when(mRxPermissions.isMarshmallow()).thenReturn(true);
Activity activity = mock(Activity.class);
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 eachSubscription_denied.
@Test
@TargetApi(Build.VERSION_CODES.M)
public void eachSubscription_denied() {
TestObserver<Permission> sub = new TestObserver<>();
String permission = Manifest.permission.READ_PHONE_STATE;
when(mRxPermissions.isGranted(permission)).thenReturn(false);
int[] result = new int[] { PackageManager.PERMISSION_DENIED };
trigger().compose(mRxPermissions.ensureEach(permission)).subscribe(sub);
mRxPermissions.onRequestPermissionsResult(new String[] { permission }, result);
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 eachSubscriptionCombined_revoked.
@Test
@TargetApi(Build.VERSION_CODES.M)
public void eachSubscriptionCombined_revoked() {
TestObserver<Permission> sub = new TestObserver<>();
String permission = Manifest.permission.READ_PHONE_STATE;
when(mRxPermissions.isRevoked(permission)).thenReturn(true);
trigger().compose(mRxPermissions.ensureEachCombined(permission)).subscribe(sub);
sub.assertNoErrors();
sub.assertTerminated();
sub.assertValue(new Permission(permission, false));
}
Aggregations