@Test @ExecuteOnNonUiThread public void testOnMainThreadPropertyChangeListener() { Assume.assumeTrue("Test is only reliable on Windows", System.getProperty("os.name").contains("Windows")); final DisplayRunner displayInit = new DisplayRunner(); final Thread background = new Thread(displayInit); background.start(); sleep(1000); final PropertyChangeEventRecorder recorder = new PropertyChangeEventRecorder(displayInit.getDisplay()); source = new BasicEventList<>(); countCalc = Calculations.count(source); countProxyCalc = CalculationsSWT.swtThreadProxyCalculation(countCalc, displayInit.getDisplay()); countProxyCalc.addPropertyChangeListener(recorder); assertEquals(0, recorder.getCallbackCount()); assertNull(recorder.getLastCallbackOldValue()); assertNull(recorder.getLastCallbackNewValue()); source.add("one"); sleep(300); assertEquals(1, recorder.getCallbackCount()); assertTrue(recorder.getLastCallbackThreadWasDisplayThread()); assertEquals(Integer.valueOf(0), recorder.getLastCallbackOldValue()); assertEquals(Integer.valueOf(1), recorder.getLastCallbackNewValue()); recorder.reset(); source.addAll(Arrays.asList("two", "three")); sleep(300); assertEquals(1, recorder.getCallbackCount()); assertTrue(recorder.getLastCallbackThreadWasDisplayThread()); assertEquals(Integer.valueOf(1), recorder.getLastCallbackOldValue()); assertEquals(Integer.valueOf(3), recorder.getLastCallbackNewValue()); recorder.reset(); source.remove(1); sleep(300); assertEquals(1, recorder.getCallbackCount()); assertTrue(recorder.getLastCallbackThreadWasDisplayThread()); assertEquals(Integer.valueOf(3), recorder.getLastCallbackOldValue()); assertEquals(Integer.valueOf(2), recorder.getLastCallbackNewValue()); recorder.reset(); source.clear(); sleep(300); assertEquals(1, recorder.getCallbackCount()); assertTrue(recorder.getLastCallbackThreadWasDisplayThread()); assertEquals(Integer.valueOf(2), recorder.getLastCallbackOldValue()); assertEquals(Integer.valueOf(0), recorder.getLastCallbackNewValue()); recorder.reset(); try { displayInit.stop(); background.join(); } catch (InterruptedException e) { throw new RuntimeException(e); } }
public SWTThreadProxyCalculation(Calculation<? extends E> source, Display display) { super(source); this.display = display; }
SWTThreadProxyCalculation extends ThreadProxyCalculation<E> { public SWTThreadProxyCalculation(Calculation<? extends E> source, Display display) { super(source); this.display = display; } }
SWTThreadProxyCalculation extends ThreadProxyCalculation<E> { public SWTThreadProxyCalculation(Calculation<? extends E> source, Display display) { super(source); this.display = display; } SWTThreadProxyCalculation(Calculation<? extends E> source, Display display); }
SWTThreadProxyCalculation extends ThreadProxyCalculation<E> { public SWTThreadProxyCalculation(Calculation<? extends E> source, Display display) { super(source); this.display = display; } SWTThreadProxyCalculation(Calculation<? extends E> source, Display display);  }
SWTThreadProxyCalculation extends ThreadProxyCalculation<E> { public SWTThreadProxyCalculation(Calculation<? extends E> source, Display display) { super(source); this.display = display; } SWTThreadProxyCalculation(Calculation<? extends E> source, Display display);   }