@Test public void testFindByIdWithGrandchildren() { StubFlowPanel parent = new StubFlowPanel(); StubFlowPanel child = new StubFlowPanel(); StubFlowPanel grandchild = new StubFlowPanel(); grandchild.ensureDebugId("grandchild"); parent.add(child); child.add(grandchild); assertThat(parent.findById("grandchild"), is(sameInstance((IsWidget) grandchild))); }
@Test public void testClear() { StubFlowPanel p = new StubFlowPanel(); p.add(new StubTextBox()); p.clear(); }
@Test public void oldPresentersAreRemovedFromPanel() { binder.bind(names).to(parent, panel, presenterFactory); names.add("one"); names.add("two"); assertThat(panel.getWidgetCount(), is(2)); assertThat(parent.getChildren().size(), is(2)); names.remove("one"); assertThat(panel.getWidgetCount(), is(1)); assertLabel(panel.getIsWidget(0), "two"); assertThat(parent.getChildren().size(), is(1)); }
@Test public void testCannotDropAnchorOnToALabel() { v.l1().dragStart(); v.a1().drop(); assertThat(v.rootAnchors().getIsWidget(0), is(v.a1())); assertThat(v.rootLabels().getIsWidget(0), is(v.l1())); }
private SomeUiXmlView() { panel = new StubFlowPanel(); box = new StubTextBox(); component = new SomeComponent(); panel.add(box); panel.add(component); setWidget(box); ensureDebugId("SomeUiXml"); } }
@Test public void newNamesAreAddedAfterExistingContent() { panel.add(viewFactory.create("existing")); binder.bind(names).to(panel, viewFactory); names.add("one"); assertLabel(panel.getIsWidget(0), "existing"); assertLabel(panel.getIsWidget(1), "one"); }
@Override public IsFlowPanel newFlowPanel() { return new StubFlowPanel(); }
@Test public void whenIsAttach() { final BooleanProperty b = booleanProperty("b", false); final StubWidget w = new StubWidget(); final StubFlowPanel p = new StubFlowPanel(); binder.when(b).is(true).attach(w).to(p); assertThat(p.getWidgetCount(), is(0)); b.set(true); assertThat(p.getWidgetCount(), is(1)); b.set(false); assertThat(p.getWidgetCount(), is(0)); }
@Override public void insert(com.google.gwt.user.client.ui.IsWidget widget, int beforeIndex) { add(beforeIndex, widget); }
@Test public void bindDoesNotNullPointerExceptionForViews() { names.set(null); binder.bind(names).to(panel, viewFactory); names.set(Copy.list("one")); assertThat(panel.getWidgetCount(), is(1)); }
@Test public void newPresentersAreAddedToPanel() { binder.bind(names).to(parent, panel, presenterFactory); assertThat(panel.getWidgetCount(), is(0)); names.add("one"); assertLabel(panel.getIsWidget(0), "one"); assertThat(parent.getChildren().size(), is(1)); }
@Test public void initialPresentersAreAddedToPanel() { names.add("one"); names.add("two"); binder.bind(names).to(parent, panel, presenterFactory); assertLabel(panel.getIsWidget(0), "one"); assertLabel(panel.getIsWidget(1), "two"); assertThat(parent.getChildren().size(), is(2)); }
public ParentPresenter() { super(new StubFlowPanel()); }
@Test public void bindDoesNotNullPointerExceptionForPresenters() { names.set(null); ParentPresenter parent = bind(new ParentPresenter()); binder.bind(names).to(parent, panel, presenterFactory); names.set(Copy.list("one")); assertThat(panel.getWidgetCount(), is(1)); }
@Test public void testFindByIdWithChildren() { StubFlowPanel parent = new StubFlowPanel(); StubFlowPanel child = new StubFlowPanel(); child.ensureDebugId("child"); parent.add(child); assertThat(parent.findById("child"), is(sameInstance((IsWidget) child))); }
@Test public void reordersToDoNotRequireCreatingNewViews() { binder.bind(names).to(panel, viewFactory); names.set(list("one", "two")); assertThat(panel.getWidgetCount(), is(2)); assertLabel(panel.getIsWidget(0), "one"); assertThat(viewFactory.created, is(2)); names.set(list("two", "one")); assertThat(panel.getWidgetCount(), is(2)); assertLabel(panel.getIsWidget(0), "two"); assertThat(viewFactory.created, is(2)); }
@Test public void newNamesAreAddedWithIndexToPanel() { binder.bind(names).to(panel, viewFactory); names.add("one"); assertLabel(panel.getIsWidget(0), "one"); names.add(0, "two"); assertLabel(panel.getIsWidget(0), "two"); }
@Test public void styleOf() { StubFlowPanel p = new StubFlowPanel(); TakesValue<String> style = TakesValues.styleOf(p); assertThat(style.getValue(), is(nullValue())); style.setValue("foo"); assertThat(p, hasStyle("foo")); assertThat(style.getValue(), is("foo")); style.setValue("bar"); assertThat(p, hasStyle("bar")); assertThat(p, not(hasStyle("foo"))); assertThat(style.getValue(), is("bar")); style.setValue(null); assertThat(p, not(hasStyle("bar"))); assertThat(style.getValue(), is(nullValue())); style.setValue(""); assertThat(style.getValue(), is(nullValue())); } }
@Test public void testFindByIdWithCompositeIsWidget() { StubFlowPanel parent = new StubFlowPanel(); StubFlowPanel uiXmlContent = new StubFlowPanel(); uiXmlContent.ensureDebugId("uiXmlContent"); CompositeIsWidget c = new CompositeIsWidget(); c.setWidget(uiXmlContent); parent.add(c); assertThat(parent.findById("uiXmlContent"), is(sameInstance((IsWidget) uiXmlContent))); }
@Test public void reordersToDoNotRequireCreatingNewPresenters() { binder.bind(names).to(parent, panel, presenterFactory); names.set(list("one", "two")); assertThat(panel.getWidgetCount(), is(2)); assertLabel(panel.getIsWidget(0), "one"); assertThat(presenterFactory.created, is(2)); names.set(list("two", "one")); assertThat(panel.getWidgetCount(), is(2)); assertLabel(panel.getIsWidget(0), "two"); assertThat(presenterFactory.created, is(2)); }