コード例 #1
0
 @Test
 public void bindDoesNotNullPointerExceptionForViews() {
   names.set(null);
   binder.bind(names).to(panel, viewFactory);
   names.set(Copy.list("one"));
   assertThat(panel.getWidgetCount(), is(1));
 }
コード例 #2
0
 @Test
 public void newNamesAreAddedToPanel() {
   binder.bind(names).to(panel, viewFactory);
   assertThat(panel.getWidgetCount(), is(0));
   names.add("one");
   assertLabel(panel.getIsWidget(0), "one");
 }
コード例 #3
0
 @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");
 }
コード例 #4
0
 @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");
 }
コード例 #5
0
 @Test
 public void initialNamesAreAddedToPanel() {
   names.add("one");
   names.add("two");
   binder.bind(names).to(panel, viewFactory);
   assertLabel(panel.getIsWidget(0), "one");
   assertLabel(panel.getIsWidget(1), "two");
 }
コード例 #6
0
 @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));
 }
コード例 #7
0
 @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));
 }
コード例 #8
0
 @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));
 }
コード例 #9
0
 @Test
 public void oldNamesAreRemovedFromPanel() {
   binder.bind(names).to(panel, viewFactory);
   names.add("one");
   names.add("two");
   assertThat(panel.getWidgetCount(), is(2));
   names.remove("one");
   assertThat(panel.getWidgetCount(), is(1));
   assertLabel(panel.getIsWidget(0), "two");
 }
コード例 #10
0
 @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));
 }
コード例 #11
0
  @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));
  }