protected void setUp() throws Exception { Fixture.setUp(); display = new Display(); shell = new Shell(display, SWT.NONE); lca = new ScaleLCA(); Fixture.fakeNewRequest(display); }
@Test public void testFireFocusEventBeforeMouseEvent() { final java.util.List<TypedEvent> eventLog = new ArrayList<TypedEvent>(); Button button = new Button(shell, SWT.PUSH); getRemoteObject(button).setHandler(new ButtonOperationHandler(button)); Fixture.markInitialized(button); button.addMouseListener( new MouseAdapter() { @Override public void mouseDown(MouseEvent event) { eventLog.add(event); } }); button.addFocusListener( new FocusAdapter() { @Override public void focusGained(FocusEvent event) { eventLog.add(event); } }); Fixture.fakeNewRequest(); fakeMouseDownRequest(button, 1, 2); Fixture.fakeSetProperty(getId(display), "focusControl", getId(button)); Fixture.fakeNotifyOperation(getId(button), EVENT_FOCUS_IN, null); Fixture.executeLifeCycleFromServerThread(); assertEquals(FocusEvent.class, eventLog.get(0).getClass()); assertEquals(MouseEvent.class, eventLog.get(1).getClass()); }
@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)); }
@Before public void setUp() { Fixture.setUp(); Fixture.fakePhase(PhaseId.PROCESS_ACTION); display = new Display(); shell = new Shell(display); text = new Text(shell, SWT.NONE); }
@Before public void setUp() { Fixture.setUp(); display = new Display(); shell = new Shell(display); progressBar = new ProgressBar(shell, SWT.NONE); lca = new ProgressBarLCA(); Fixture.fakeNewRequest(); }
@Before public void setUp() { Fixture.setUp(); display = new Display(); shell = new Shell(display, SWT.NONE); combo = new Combo(shell, SWT.NONE); lca = new ComboLCA(); Fixture.fakeNewRequest(); }
@Before public void setUp() { Fixture.setUp(); Fixture.fakePhase(PhaseId.PROCESS_ACTION); display = new Display(); menuItem = mock(MenuItem.class); menuItem.display = display; acceleratorSupport = new AcceleratorBinding(menuItem); }
@Test public void testReadData_TextAndSelection() { Fixture.fakeSetParameter(getId(combo), "text", "abc"); Fixture.fakeSetParameter(getId(combo), "selectionStart", Integer.valueOf(1)); Fixture.fakeSetParameter(getId(combo), "selectionLength", Integer.valueOf(1)); lca.readData(combo); assertEquals(new Point(1, 2), combo.getSelection()); }
@Before public void setUp() { Fixture.setUp(); Fixture.fakePhase(PhaseId.PROCESS_ACTION); display = new Display(); shell = new Shell(display); tree = new Tree(shell, SWT.NONE); column = new TreeColumn(tree, SWT.NONE); eventLog = new ArrayList<Event>(); }
@Test public void testFireDefaultSelectionEvent() { SelectionListener listener = mock(SelectionListener.class); combo.addSelectionListener(listener); Fixture.fakeNotifyOperation(getId(combo), ClientMessageConst.EVENT_DEFAULT_SELECTION, null); Fixture.readDataAndProcessAction(combo); verify(listener, times(1)).widgetDefaultSelected(any(SelectionEvent.class)); }
@Test public void testRenderItemHeightUnchanged() throws IOException { Fixture.markInitialized(display); Fixture.markInitialized(combo); combo.setFont(new Font(display, "Arial", 16, SWT.NONE)); Fixture.preserveWidgets(); lca.renderChanges(combo); Message message = Fixture.getProtocolMessage(); assertNull(message.findSetOperation(combo, "itemHeight")); }
@Test public void testRenderItemsUnchanged() throws IOException { Fixture.markInitialized(display); Fixture.markInitialized(combo); combo.setItems(new String[] {"a", "b", "c"}); Fixture.preserveWidgets(); lca.renderChanges(combo); Message message = Fixture.getProtocolMessage(); assertNull(message.findSetOperation(combo, "items")); }
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")); }
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")); }
@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 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 testRenderListVisibleUnchanged() throws IOException { Fixture.markInitialized(display); Fixture.markInitialized(combo); combo.setListVisible(true); Fixture.preserveWidgets(); lca.renderChanges(combo); Message message = Fixture.getProtocolMessage(); assertNull(message.findSetOperation(combo, "listVisible")); }
@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")); }
@Test public void testListenDefaultSelection() throws Exception { Fixture.markInitialized(display); Fixture.markInitialized(combo); Fixture.preserveWidgets(); combo.addListener(SWT.DefaultSelection, mock(Listener.class)); lca.renderChanges(combo); Message message = Fixture.getProtocolMessage(); assertNull(message.findListenOperation(combo, "Selection")); assertEquals(Boolean.TRUE, message.findListenProperty(combo, "DefaultSelection")); }
public void testRenderSelectionListenerUnchanged() throws Exception { Scale scale = new Scale(shell, SWT.NONE); Fixture.markInitialized(display); Fixture.markInitialized(scale); Fixture.preserveWidgets(); scale.addSelectionListener(new SelectionAdapter() {}); Fixture.preserveWidgets(); lca.renderChanges(scale); Message message = Fixture.getProtocolMessage(); assertNull(message.findListenOperation(scale, "selection")); }
@Test public void testRenderSelectionListenerUnchanged() throws Exception { Fixture.markInitialized(display); Fixture.markInitialized(combo); Fixture.preserveWidgets(); combo.addSelectionListener(new SelectionAdapter() {}); Fixture.preserveWidgets(); lca.renderChanges(combo); Message message = Fixture.getProtocolMessage(); assertNull(message.findListenOperation(combo, "selection")); }
@Test public void testRenderSelectionUnchanged() throws IOException { combo.setText("foo bar"); Fixture.markInitialized(display); Fixture.markInitialized(combo); combo.setSelection(new Point(1, 3)); Fixture.preserveWidgets(); lca.renderChanges(combo); Message message = Fixture.getProtocolMessage(); assertNull(message.findSetOperation(combo, "selection")); }
@Test public void testRenderTextLimitResetWithNegative() throws IOException { Fixture.markInitialized(display); Fixture.markInitialized(combo); combo.setTextLimit(10); Fixture.preserveWidgets(); combo.setTextLimit(-5); lca.renderChanges(combo); Message message = Fixture.getProtocolMessage(); assertEquals(JSONObject.NULL, message.findSetProperty(combo, "textLimit")); }
public void testStartupRequestWithParameter() throws Exception { RWTFactory.getEntryPointManager().registerByPath("/rap", DefaultEntryPoint.class, null); Fixture.fakeNewGetRequest(); Fixture.fakeRequestParam("param", "value"); RWTFactory.getServiceManager().getHandler().service(); Fixture.fakeNewRequest(); Fixture.fakeRequestParam("param", null); Fixture.fakeRequestParam(RequestParams.RWT_INITIALIZE, "true"); RWTFactory.getServiceManager().getHandler().service(); assertEquals("value", ContextProvider.getRequest().getParameter("param")); }
@Test public void testEditablePreserveValues() { Fixture.markInitialized(display); Fixture.preserveWidgets(); WidgetAdapter adapter = WidgetUtil.getAdapter(combo); assertEquals(Boolean.TRUE, adapter.getPreserved(ComboLCA.PROP_EDITABLE)); Fixture.clearPreserved(); // textLimit combo.setTextLimit(10); Fixture.preserveWidgets(); Integer textLimit = (Integer) adapter.getPreserved(ComboLCA.PROP_TEXT_LIMIT); assertEquals(new Integer(10), textLimit); }
@Test public void testRemoveListenSelection() throws Exception { Fixture.markInitialized(display); Fixture.markInitialized(combo); Listener listener = mock(Listener.class); combo.addListener(SWT.Selection, listener); Fixture.preserveWidgets(); combo.removeListener(SWT.Selection, listener); lca.renderChanges(combo); Message message = Fixture.getProtocolMessage(); assertEquals(Boolean.FALSE, message.findListenProperty(combo, "Selection")); }
@Test public void testRenderAddVerifyListener() throws Exception { Fixture.markInitialized(display); Fixture.markInitialized(combo); Fixture.preserveWidgets(); combo.addVerifyListener( new VerifyListener() { public void verifyText(VerifyEvent event) {} }); lca.renderChanges(combo); Message message = Fixture.getProtocolMessage(); assertEquals(Boolean.TRUE, message.findListenProperty(combo, "Modify")); }
@Before public void setUp() { Fixture.setUp(); new Display(); gc = mock(GC.class); dispatcher = new GCOperationDispatcher(gc, ClientCanvasTestUtil.createDrawings(3)); }
@Test public void testPreserveValues() { Fixture.preserveWidgets(); WidgetAdapter adapter = WidgetUtil.getAdapter(progressBar); Object preserved = adapter.getPreserved(ProgressBarLCA.PROP_STATE); assertNull(preserved); }
@Test public void testPreservesOptions() { Fixture.fakePhase(PhaseId.READ_DATA); when(adapter.getFlavor()).thenReturn(NeedsPositionFlavor.CONTINUOUS); GeolocationOptions options = new GeolocationOptions().setFrequency(10).enableHighAccuracy().setMaximumAge(10); when(adapter.getOptions()).thenReturn(options); synchronizer.preserveValues(object); assertNotNull( RWT.getServiceStore() .getAttribute( synchronizer.getObjectId() + "." + GeolocationSynchronizer.PROP_ENABLE_HIGH_ACCURACY)); assertNotNull( RWT.getServiceStore() .getAttribute( synchronizer.getObjectId() + "." + GeolocationSynchronizer.PROP_FREQUENCY)); assertNotNull( RWT.getServiceStore() .getAttribute( synchronizer.getObjectId() + "." + GeolocationSynchronizer.PROP_MAXIMUM_AGE)); }