@Test public void testSelectionAfterRemoveAll() { combo = new Combo(shell, SWT.READ_ONLY); Fixture.markInitialized(display); Fixture.markInitialized(combo); combo.add("item 1"); combo.select(0); Button button = new Button(shell, SWT.PUSH); button.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { combo.removeAll(); combo.add("replacement for item 1"); combo.select(0); } }); // Simulate button click that executes widgetSelected Fixture.fakeNotifyOperation(getId(button), ClientMessageConst.EVENT_SELECTION, null); Fixture.executeLifeCycleFromServerThread(); Message message = Fixture.getProtocolMessage(); assertEquals(new Integer(0), message.findSetProperty(combo, PROP_SELECTION_INDEX)); }
@Test public void testRenderItemHeight() throws IOException { combo.setFont(new Font(display, "Arial", 16, SWT.NONE)); lca.renderChanges(combo); Message message = Fixture.getProtocolMessage(); assertEquals(new Integer(22), message.findSetProperty(combo, "itemHeight")); }
@Test public void testRenderCreate() throws IOException { lca.renderInitialization(progressBar); Message message = Fixture.getProtocolMessage(); CreateOperation operation = message.findCreateOperation(progressBar); assertEquals("rwt.widgets.ProgressBar", operation.getType()); }
@Test public void testRenderState() throws IOException { progressBar.setState(SWT.ERROR); lca.renderChanges(progressBar); Message message = Fixture.getProtocolMessage(); assertEquals("error", message.findSetProperty(progressBar, "state").asString()); }
@Test public void testRenderSelection() throws IOException { progressBar.setSelection(10); lca.renderChanges(progressBar); Message message = Fixture.getProtocolMessage(); assertEquals(10, message.findSetProperty(progressBar, "selection").asInt()); }
@Test public void testRenderListVisible() throws IOException { combo.setListVisible(true); lca.renderChanges(combo); Message message = Fixture.getProtocolMessage(); assertEquals(Boolean.TRUE, message.findSetProperty(combo, "listVisible")); }
@Test public void testRenderInitialState() throws IOException { lca.render(progressBar); Message message = Fixture.getProtocolMessage(); CreateOperation operation = message.findCreateOperation(progressBar); assertTrue(operation.getPropertyNames().indexOf("state") == -1); }
@Test public void testRenderParent() throws IOException { lca.renderInitialization(progressBar); Message message = Fixture.getProtocolMessage(); CreateOperation operation = message.findCreateOperation(progressBar); assertEquals(WidgetUtil.getId(progressBar.getParent()), operation.getParent()); }
@Test public void testRenderInitialItemHeight() throws IOException { lca.render(combo); Message message = Fixture.getProtocolMessage(); CreateOperation operation = message.findCreateOperation(combo); assertTrue(operation.getPropertyNames().contains("itemHeight")); }
@Test public void testRenderInitialTextLimit() throws IOException { lca.render(combo); Message message = Fixture.getProtocolMessage(); CreateOperation operation = message.findCreateOperation(combo); assertTrue(operation.getPropertyNames().indexOf("textLimit") == -1); }
@Test public void testRenderTextLimit() throws IOException { combo.setTextLimit(10); lca.renderChanges(combo); Message message = Fixture.getProtocolMessage(); assertEquals(new Integer(10), message.findSetProperty(combo, "textLimit")); }
@Test public void testRenderText() throws IOException { combo.setText("foo"); lca.renderChanges(combo); Message message = Fixture.getProtocolMessage(); assertEquals("foo", message.findSetProperty(combo, "text")); }
public void testRenderMaxmum() throws IOException { Scale scale = new Scale(shell, SWT.NONE); scale.setMaximum(10); lca.renderChanges(scale); Message message = Fixture.getProtocolMessage(); assertEquals(new Integer(10), message.findSetProperty(scale, "maximum")); }
public void testRenderPageIncrement() throws IOException { Scale scale = new Scale(shell, SWT.NONE); scale.setPageIncrement(20); lca.renderChanges(scale); Message message = Fixture.getProtocolMessage(); assertEquals(new Integer(20), message.findSetProperty(scale, "pageIncrement")); }
public void testRenderInitialPageIncrement() throws IOException { Scale scale = new Scale(shell, SWT.NONE); lca.render(scale); Message message = Fixture.getProtocolMessage(); CreateOperation operation = message.findCreateOperation(scale); assertTrue(operation.getPropertyNames().indexOf("pageIncrement") == -1); }
public void testRenderParent() throws IOException { Scale scale = new Scale(shell, SWT.NONE); lca.renderInitialization(scale); Message message = Fixture.getProtocolMessage(); CreateOperation operation = message.findCreateOperation(scale); assertEquals(WidgetUtil.getId(scale.getParent()), operation.getParent()); }
public void testRenderCreate() throws IOException { Scale scale = new Scale(shell, SWT.NONE); lca.renderInitialization(scale); Message message = Fixture.getProtocolMessage(); CreateOperation operation = message.findCreateOperation(scale); assertEquals("rwt.widgets.Scale", operation.getType()); }
@Test public void testRenderChanges_rendersClientListener() throws IOException { progressBar.addListener(SWT.MouseEnter, new ClientListener("")); lca.renderChanges(progressBar); Message message = Fixture.getProtocolMessage(); assertNotNull(message.findCallOperation(progressBar, "addListener")); }
@Test public void testRenderTextNotEditable() throws IOException { Combo combo = new Combo(shell, SWT.READ_ONLY); combo.setText("foo"); lca.renderChanges(combo); Message message = Fixture.getProtocolMessage(); assertNull(message.findSetOperation(combo, "text")); }
@Test public void testRenderSelectionIndex() throws IOException { combo.setItems(new String[] {"a", "b", "c"}); combo.select(1); lca.renderChanges(combo); Message message = Fixture.getProtocolMessage(); assertEquals(new Integer(1), message.findSetProperty(combo, "selectionIndex")); }
@Test public void testRenderEditable_ReadOnly() throws IOException { Combo combo = new Combo(shell, SWT.READ_ONLY); lca.render(combo); Message message = Fixture.getProtocolMessage(); CreateOperation operation = message.findCreateOperation(combo); assertEquals(Boolean.FALSE, operation.getProperty("editable")); }
public void testRenderCreateWithHorizontal() throws IOException { Scale scale = new Scale(shell, SWT.HORIZONTAL); lca.renderInitialization(scale); Message message = Fixture.getProtocolMessage(); CreateOperation operation = message.findCreateOperation(scale); Object[] styles = operation.getStyles(); assertTrue(Arrays.asList(styles).contains("HORIZONTAL")); }
@Test public void testRenderItems() throws IOException, JSONException { combo.setItems(new String[] {"a", "b", "c"}); lca.renderChanges(combo); Message message = Fixture.getProtocolMessage(); String expected = "[ \"a\", \"b\", \"c\" ]"; JSONArray actual = (JSONArray) message.findSetProperty(combo, "items"); assertTrue(ProtocolTestUtil.jsonEquals(expected, actual)); }
@Test public void testRenderSelection() throws IOException, JSONException { combo.setText("foo bar"); combo.setSelection(new Point(1, 3)); lca.renderChanges(combo); Message message = Fixture.getProtocolMessage(); JSONArray actual = (JSONArray) message.findSetProperty(combo, "selection"); assertTrue(ProtocolTestUtil.jsonEquals("[ 1, 3 ]", actual)); }
@Test public void testRenderStateUnchanged() throws IOException { Fixture.markInitialized(display); Fixture.markInitialized(progressBar); progressBar.setState(SWT.ERROR); Fixture.preserveWidgets(); lca.renderChanges(progressBar); Message message = Fixture.getProtocolMessage(); assertNull(message.findSetOperation(progressBar, "state")); }
@Test public void testRenderTextLimitUnchanged() throws IOException { Fixture.markInitialized(display); Fixture.markInitialized(combo); combo.setTextLimit(10); Fixture.preserveWidgets(); lca.renderChanges(combo); Message message = Fixture.getProtocolMessage(); assertNull(message.findSetOperation(combo, "textLimit")); }
public void testRenderPageIncrementUnchanged() throws IOException { Scale scale = new Scale(shell, SWT.NONE); Fixture.markInitialized(display); Fixture.markInitialized(scale); scale.setPageIncrement(20); Fixture.preserveWidgets(); lca.renderChanges(scale); Message message = Fixture.getProtocolMessage(); assertNull(message.findSetOperation(scale, "pageIncrement")); }
public void testRenderAddSelectionListener() throws Exception { Scale scale = new Scale(shell, SWT.NONE); Fixture.markInitialized(display); Fixture.markInitialized(scale); Fixture.preserveWidgets(); scale.addSelectionListener(new SelectionAdapter() {}); lca.renderChanges(scale); Message message = Fixture.getProtocolMessage(); assertEquals(Boolean.TRUE, message.findListenProperty(scale, "selection")); }
@Test public void testRenderMaxmumUnchanged() throws IOException { Fixture.markInitialized(display); Fixture.markInitialized(progressBar); progressBar.setMaximum(10); Fixture.preserveWidgets(); lca.renderChanges(progressBar); Message message = Fixture.getProtocolMessage(); assertNull(message.findSetOperation(progressBar, "maximum")); }
@Test public void testRenderCreateWithVerticalAndIndeterminate() throws IOException { progressBar = new ProgressBar(shell, SWT.VERTICAL | SWT.INDETERMINATE); lca.renderInitialization(progressBar); Message message = Fixture.getProtocolMessage(); CreateOperation operation = message.findCreateOperation(progressBar); Object[] styles = operation.getStyles(); assertTrue(Arrays.asList(styles).contains("VERTICAL")); assertTrue(Arrays.asList(styles).contains("INDETERMINATE")); }