use of org.eclipse.scout.rt.client.ui.form.fields.FormFieldVisibilityTest.P_GroupBox.P_TabBox.Tab1 in project scout.rt by eclipse.
the class FormFieldVisibilityTest method testVisitParents.
@Test
public void testVisitParents() {
ICompositeField root = createFixture();
final AtomicInteger counter01 = new AtomicInteger(0);
root.getFieldByClass(P_Seq.class).visitParents(new IFormFieldVisitor() {
@Override
public boolean visitField(IFormField f, int level, int fieldIndex) {
counter01.incrementAndGet();
return true;
}
});
Assert.assertEquals(4, counter01.intValue());
final AtomicInteger counter02 = new AtomicInteger(0);
root.getFieldByClass(P_Button2.class).visitParents(new IFormFieldVisitor() {
@Override
public boolean visitField(IFormField f, int level, int fieldIndex) {
counter02.incrementAndGet();
return true;
}
});
Assert.assertEquals(2, counter02.intValue());
final AtomicInteger counter03 = new AtomicInteger(0);
root.visitParents(new IFormFieldVisitor() {
@Override
public boolean visitField(IFormField f, int level, int fieldIndex) {
counter03.incrementAndGet();
return true;
}
});
Assert.assertEquals(0, counter03.intValue());
final AtomicInteger counter04 = new AtomicInteger(0);
final Holder<Object> lastVisited = new Holder<>(Object.class);
root.getFieldByClass(P_Seq.class).visitParents(new IFormFieldVisitor() {
@Override
public boolean visitField(IFormField f, int level, int fieldIndex) {
counter04.incrementAndGet();
lastVisited.setValue(f);
return counter04.intValue() <= 1;
}
});
Assert.assertEquals(2, counter04.intValue());
Assert.assertSame(lastVisited.getValue(), root.getFieldByClass(Tab1.class));
}
Aggregations