@Test public void waitForCallback() throws InterruptedException { mSource.setCallback(null); Thread thread = new Thread() { @Override public void run() { mSource.waitForCallback(); } }; thread.start(); mSource.setCallback(mCallback); thread.join(100); assertEquals(mCallback,mSource.getCallback()); }
protected void waitForCallback() { try { mCallbackLock.lock(); if(mCallback == null) { mCallbackChanged.await(); } } catch(InterruptedException e) { Log.w(TAG, "Interrupted..."); e.printStackTrace(); Thread.currentThread().interrupt(); } finally { mCallbackLock.unlock(); } }
BaseVehicleDataSource implements VehicleDataSource { protected void waitForCallback() { try { mCallbackLock.lock(); if(mCallback == null) { mCallbackChanged.await(); } } catch(InterruptedException e) { Log.w(TAG, "Interrupted..."); e.printStackTrace(); Thread.currentThread().interrupt(); } finally { mCallbackLock.unlock(); } } }
BaseVehicleDataSource implements VehicleDataSource { protected void waitForCallback() { try { mCallbackLock.lock(); if(mCallback == null) { mCallbackChanged.await(); } } catch(InterruptedException e) { Log.w(TAG, "Interrupted..."); e.printStackTrace(); Thread.currentThread().interrupt(); } finally { mCallbackLock.unlock(); } } BaseVehicleDataSource();  BaseVehicleDataSource(SourceCallback callback); }
BaseVehicleDataSource implements VehicleDataSource { protected void waitForCallback() { try { mCallbackLock.lock(); if(mCallback == null) { mCallbackChanged.await(); } } catch(InterruptedException e) { Log.w(TAG, "Interrupted..."); e.printStackTrace(); Thread.currentThread().interrupt(); } finally { mCallbackLock.unlock(); } } BaseVehicleDataSource();  BaseVehicleDataSource(SourceCallback callback); @Override void setCallback(SourceCallback callback); abstract boolean isConnected(); @Override void stop(); @Override void onPipelineActivated(); @Override void onPipelineDeactivated(); SourceCallback getCallback(); }
BaseVehicleDataSource implements VehicleDataSource { protected void waitForCallback() { try { mCallbackLock.lock(); if(mCallback == null) { mCallbackChanged.await(); } } catch(InterruptedException e) { Log.w(TAG, "Interrupted..."); e.printStackTrace(); Thread.currentThread().interrupt(); } finally { mCallbackLock.unlock(); } } BaseVehicleDataSource();  BaseVehicleDataSource(SourceCallback callback); @Override void setCallback(SourceCallback callback); abstract boolean isConnected(); @Override void stop(); @Override void onPipelineActivated(); @Override void onPipelineDeactivated(); SourceCallback getCallback();  }