GooglePlayReceiver extends Service implements ExecutionDelegator.JobFinishedCallback { @Nullable @Override public IBinder onBind(Intent intent) { if (intent == null || Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP || !ACTION_EXECUTE.equals(intent.getAction())) { return null; } return getServiceMessenger().getBinder(); }  @Override final int onStartCommand(Intent intent, int flags, int startId); @Nullable @Override IBinder onBind(Intent intent); @Override void onJobFinished(@NonNull JobInvocation js, @JobResult int result);  }
@Test public void onBind() { Intent intent = new Intent(GooglePlayReceiver.ACTION_EXECUTE); IBinder binderA = receiver.onBind(intent); IBinder binderB = receiver.onBind(intent); assertEquals(binderA, binderB); }
@Test public void onBind_nullIntent() { IBinder binder = receiver.onBind(null); assertNull(binder); }
@Test public void onBind_wrongAction() { Intent intent = new Intent("test"); IBinder binder = receiver.onBind(intent); assertNull(binder); }
@Test @Config(sdk = VERSION_CODES.KITKAT) public void onBind_wrongBuild() { Intent intent = new Intent(GooglePlayReceiver.ACTION_EXECUTE); IBinder binder = receiver.onBind(intent); assertNull(binder); }