use of org.eclipse.scout.rt.client.ui.form.fields.smartfield.SmartFieldTest.TestForm.MainBox.StyleField in project scout.rt by eclipse.
the class SmartFieldTest method testStyle_SetValue.
@Test
public void testStyle_SetValue() throws Throwable {
StyleField f = m_styleField;
f.setValue(10L);
assertRedFieldStyle(f);
f.setValue(50L);
assertDefaultFieldStyle(f);
f.setValue(20L);
assertYellowFieldStyle(f);
f.setValue(null);
assertDefaultFieldStyle(f);
}
use of org.eclipse.scout.rt.client.ui.form.fields.smartfield.SmartFieldTest.TestForm.MainBox.StyleField in project scout.rt by eclipse.
the class SmartFieldTest method testHierarchicalOpenProposal.
@Test
public void testHierarchicalOpenProposal() {
StyleField f = m_styleField;
f.setBrowseHierarchy(true);
f.setValue(10L);
f.getUIFacade().openProposalChooserFromUI("Red", false, true);
waitForProposalResult(IProposalChooser.PROP_SEARCH_RESULT);
// single result
assertTrue(m_styleField.isProposalChooserRegistered());
assertEquals("Red", m_styleField.getDisplayText());
// verifies tree is loaded containing a single node
@SuppressWarnings("unchecked") TreeProposalChooser<Long> treeProposalChooser = (TreeProposalChooser<Long>) f.getProposalChooser();
ITree tree = treeProposalChooser.getModel();
ITreeNode rootNode = tree.getRootNode();
assertEquals(5, rootNode.getChildNodes().size());
assertEquals("Red", rootNode.getChildNode(0).getCell().getText());
// current value should be selected
assertTrue(rootNode.getChildNode(0).isSelectedNode());
}
use of org.eclipse.scout.rt.client.ui.form.fields.smartfield.SmartFieldTest.TestForm.MainBox.StyleField in project scout.rt by eclipse.
the class SmartFieldTest method testCancelledProposal.
/**
* Opening and closing proposal chooser without selecting a value should not change the state of the field.
*/
@Test
public void testCancelledProposal() {
Long initialValue = 10L;
StyleField f = m_styleField;
f.setValue(initialValue);
ILookupRow<Long> initialLookupRow = f.getCurrentLookupRow();
f.getUIFacade().openProposalChooserFromUI("Red", false, true);
f.getUIFacade().cancelProposalChooserFromUI();
assertEquals(initialValue, f.getValue());
assertEquals(initialLookupRow, f.getCurrentLookupRow());
}
use of org.eclipse.scout.rt.client.ui.form.fields.smartfield.SmartFieldTest.TestForm.MainBox.StyleField in project scout.rt by eclipse.
the class SmartFieldTest method testHierarchical_UIFacade.
@Test
public void testHierarchical_UIFacade() {
StyleField f = m_styleField;
f.setBrowseHierarchy(true);
f.getUIFacade().acceptProposalFromUI("Red", false, false);
assertRedFieldStyle(f);
f.getUIFacade().acceptProposalFromUI("Empty", false, false);
assertDefaultFieldStyle(f);
f.getUIFacade().acceptProposalFromUI("Yellow", false, false);
assertYellowFieldStyle(f);
f.getUIFacade().acceptProposalFromUI(null, false, false);
assertDefaultFieldStyle(f);
}
use of org.eclipse.scout.rt.client.ui.form.fields.smartfield.SmartFieldTest.TestForm.MainBox.StyleField in project scout.rt by eclipse.
the class SmartFieldTest method testLookupOnlyWhenNecessary.
/**
* Only perform a lookup when its necessary. When user has selected a lookup row from the proposal-chooser no lookup
* should be performed.
*/
@Test
public void testLookupOnlyWhenNecessary() throws Exception {
StyleField f = m_styleField;
StyleLookupCall lookupCall = (StyleLookupCall) f.getLookupCall();
// expect lookup is performed
lookupCall.allowLookup(true);
f.setValue(10L);
assertRedFieldStyle(f);
// expect lookup is not performed
lookupCall.allowLookup(false);
f.acceptProposal(createYellowLookupRow());
assertYellowFieldStyle(f);
// expect lookup is performed again
// additionally this test ensures that the lookup-row from the previous test (value=20L)
// is not reused by mistake.
lookupCall.allowLookup(true);
f.setValue(30L);
assertGreenFieldStyle(f);
}
Aggregations