use of org.eclipse.nebula.widgets.nattable.grid.data.DummyBodyDataProvider in project nebula.widgets.nattable by eclipse.
the class CalculatedValueCacheTest method testCalculateInBackgroundWithCoordsKeyKillSmooth.
@Test
public void testCalculateInBackgroundWithCoordsKeyKillSmooth() throws Exception {
this.valueCache = new CalculatedValueCache(new DataLayer(new DummyBodyDataProvider(10, 10)), true, true);
Object result = this.valueCache.getCalculatedValue(0, 0, true, this.calculator);
// as calculation is performed in background, the immediate return value
// is null
assertNull(result);
// now wait so the background process is able to finish
Thread.sleep(250);
result = this.valueCache.getCalculatedValue(0, 0, true, this.calculator);
assertEquals(Integer.valueOf(42), Integer.valueOf(result.toString()));
this.valueCache.killCache();
result = this.valueCache.getCalculatedValue(0, 0, true, this.calculator);
// killing the cache should have the same effect as clearing non smooth
assertNull(result);
}
use of org.eclipse.nebula.widgets.nattable.grid.data.DummyBodyDataProvider in project nebula.widgets.nattable by eclipse.
the class CalculatedValueCacheTest method testCalculateInBackgroundWithCoordsKeyClearSmooth.
@Test
public void testCalculateInBackgroundWithCoordsKeyClearSmooth() throws Exception {
this.valueCache = new CalculatedValueCache(new DataLayer(new DummyBodyDataProvider(10, 10)), true, true);
Object result = this.valueCache.getCalculatedValue(0, 0, true, this.calculator);
// as calculation is performed in background, the immediate return value
// is null
assertNull(result);
// now wait so the background process is able to finish
Thread.sleep(250);
result = this.valueCache.getCalculatedValue(0, 0, true, this.calculator);
assertEquals(Integer.valueOf(42), Integer.valueOf(result.toString()));
this.valueCache.clearCache();
result = this.valueCache.getCalculatedValue(0, 0, true, this.calculator);
// as the cache is configured for smooth updates, the value should be
// still there
assertEquals(Integer.valueOf(42), Integer.valueOf(result.toString()));
}
use of org.eclipse.nebula.widgets.nattable.grid.data.DummyBodyDataProvider in project nebula.widgets.nattable by eclipse.
the class CalculatedValueCacheTest method testCalculateInBackgroundWithColumnKey.
@Test
public void testCalculateInBackgroundWithColumnKey() throws Exception {
this.valueCache = new CalculatedValueCache(new DataLayer(new DummyBodyDataProvider(10, 10)), true, false);
Object result = this.valueCache.getCalculatedValue(0, 0, true, this.calculator);
// as calculation is performed in background, the immediate return value
// is null
assertNull(result);
// now wait so the background process is able to finish
Thread.sleep(250);
result = this.valueCache.getCalculatedValue(0, 0, true, this.calculator);
assertEquals(Integer.valueOf(42), Integer.valueOf(result.toString()));
}
use of org.eclipse.nebula.widgets.nattable.grid.data.DummyBodyDataProvider in project nebula.widgets.nattable by eclipse.
the class CalculatedValueCacheTest method testCalculateInBackgroundWithCoordsKeyClearNonSmooth.
@Test
public void testCalculateInBackgroundWithCoordsKeyClearNonSmooth() throws Exception {
this.valueCache = new CalculatedValueCache(new DataLayer(new DummyBodyDataProvider(10, 10)), true, true, false);
Object result = this.valueCache.getCalculatedValue(0, 0, true, this.calculator);
// as calculation is performed in background, the immediate return value
// is null
assertNull(result);
// now wait so the background process is able to finish
Thread.sleep(250);
result = this.valueCache.getCalculatedValue(0, 0, true, this.calculator);
assertEquals(Integer.valueOf(42), Integer.valueOf(result.toString()));
this.valueCache.clearCache();
result = this.valueCache.getCalculatedValue(0, 0, true, this.calculator);
// as the cache is configured for non smooth updates, the value should
// be null again
assertNull(result);
}
use of org.eclipse.nebula.widgets.nattable.grid.data.DummyBodyDataProvider in project nebula.widgets.nattable by eclipse.
the class CalculatedValueCacheTest method testCalculateInBackgroundWithRowKey.
@Test
public void testCalculateInBackgroundWithRowKey() throws Exception {
this.valueCache = new CalculatedValueCache(new DataLayer(new DummyBodyDataProvider(10, 10)), false, true);
Object result = this.valueCache.getCalculatedValue(0, 0, true, this.calculator);
// as calculation is performed in background, the immediate return value
// is null
assertNull(result);
// now wait so the background process is able to finish
Thread.sleep(250);
result = this.valueCache.getCalculatedValue(0, 0, true, this.calculator);
assertEquals(Integer.valueOf(42), Integer.valueOf(result.toString()));
}
Aggregations