@Before public void init() { context = Robolectric.setupActivity(Activity.class); shadowContext = Shadows.shadowOf(context); testingQueues = new TestingQueues(); serviceInstance = spy(new Goro.GoroImpl(testingQueues)); serviceCompName = new ComponentName(context, GoroService.class); GoroService service = new GoroService(); binder = new GoroService.GoroBinderImpl(serviceInstance, service.new GoroTasksListener()); ShadowApplication.getInstance() .setComponentNameAndServiceForBindService( serviceCompName, binder ); reset(serviceInstance); }
private GoroBinderImpl getBinder() { if (binder == null) { if (!Util.checkMainThread()) { throw new IllegalStateException( "Goro binder is being created not in the main thread. " + "This might happen if you invoke GoroService.getGoro() not from the main thread." ); } if (goro == null) { throw new IllegalStateException("GoroService is not initialized. Call GoroService.setup"); } binder = new GoroBinderImpl(goro, new GoroTasksListener()); } return binder; }
@Override public void onTaskCancel(Callable<?> task) { taskFinish(); }
@Override public void onTaskFinish(Callable<?> task, Object result) { taskFinish(); }
@Override public void onTaskError(Callable<?> task, Throwable error) { taskFinish(); } }
@Override public void onTaskError(Callable<?> task, Throwable error) { taskFinish(); } }
private GoroBinderImpl getBinder() { if (binder == null) { binder = new GoroBinderImpl(createGoro(), new GoroTasksListener()); } return binder; }
@Override public void onTaskCancel(Callable<?> task) { taskFinish(); }
@Override public void onTaskFinish(Callable<?> task, Object result) { taskFinish(); }