@Test public void testRenderInitialization_setsOperationHandler() throws IOException { String id = getId(progressBar); lca.renderInitialization(progressBar); OperationHandler handler = RemoteObjectRegistry.getInstance().get(id).getHandler(); assertTrue(handler instanceof ProgressBarOperationHandler); }
@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 testRenderCreate() throws IOException { lca.renderInitialization(progressBar); Message message = Fixture.getProtocolMessage(); CreateOperation operation = message.findCreateOperation(progressBar); assertEquals("rwt.widgets.ProgressBar", operation.getType()); }
@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 testRenderSelection() throws IOException { progressBar.setSelection(10); lca.renderChanges(progressBar); Message message = Fixture.getProtocolMessage(); assertEquals(10, message.findSetProperty(progressBar, "selection").asInt()); }
@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 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 testReadData_usesOperationHandler() { ProgressBarOperationHandler handler = spy(new ProgressBarOperationHandler(progressBar)); getRemoteObject(getId(progressBar)).setHandler(handler); Fixture.fakeNotifyOperation(getId(progressBar), "Help", new JsonObject()); lca.readData(progressBar); verify(handler).handleNotifyHelp(progressBar, new JsonObject()); }
@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 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")); }