@Test public void onClickToggleSetsNoInitialValue() { final BooleanProperty b = booleanProperty("b"); binder.onClick(anchor).toggle(b); assertThat(b.get(), is(nullValue())); }
@Test public void onClickRun() { final Boolean[] ran = { false }; binder.onClick(box).execute(new Runnable() { public void run() { ran[0] = true; } }); box.click(); assertThat(ran[0], is(true)); }
@Test public void onClickPreventDefault() { binder.onClick(box).preventDefault(); StubClickEvent e = new StubClickEvent(); box.fireEvent(e); assertThat(e.prevented, is(true)); }
@Test public void onClickAdd() { ListProperty<String> strings = listProperty("strings"); binder.onClick(anchor).add("a").to(strings); assertThat(strings.get().size(), is(0)); anchor.click(); assertThat(strings.get().size(), is(1)); }
@Test public void onClickRemove() { ListProperty<String> strings = listProperty("strings"); strings.add("a"); binder.onClick(anchor).remove("a").from(strings); assertThat(strings.get().size(), is(1)); anchor.click(); assertThat(strings.get().size(), is(0)); }
@Test public void clickableWidgetToProperty() { binder.onClick(box).set(s).to("gotclicked"); box.click(); assertThat(s.get(), is("gotclicked")); }
@Test public void onClickExecute() { DummyUiCommand c = new DummyUiCommand(); binder.onClick(box).execute(c); box.click(); assertThat(c.getExecutions(), is(1)); }
@Test public void onClickFocus() { final StubFocusWidget f = new StubFocusWidget(); binder.onClick(anchor).focus(f); anchor.click(); assertThat(f.isFocused(), is(true)); }
@Test public void onClickTogglePreventsDefault() { final BooleanProperty b = booleanProperty("b"); binder.onClick(anchor).toggle(b); final StubClickEvent c = new StubClickEvent(); anchor.fireEvent(c); assertThat(c.prevented, is(true)); }
@Test public void onClickToggleDoesActuallyToggle() { final BooleanProperty b = booleanProperty("b"); binder.onClick(anchor).toggle(b); anchor.click(); assertThat(b.get(), is(true)); anchor.click(); assertThat(b.get(), is(false)); }
@Test public void onClick() { final StubButton button = new StubButton(); binder.onClick(button).set(s).to("clicked"); button.click(); assertThat(s.get(), is("clicked")); }
@Test public void onClickMoveUp() { ListProperty<String> strings = listProperty("strings"); strings.set(list("a", "b")); binder.onClick(anchor).moveUp("b").in(strings); anchor.click(); assertThat(strings.get(), contains("b", "a")); }
@Test public void onClickGoTo() { final StubEventBus bus = new StubEventBus(); binder.onClick(box).goTo(bus, new PlaceRequest("dummy")); box.click(); assertThat(bus.getEvent(PlaceRequestEvent.class, 0).getRequest().getName(), is("dummy")); }
@Test public void onClickSort() { ListProperty<String> foo = listProperty("foo", list("b", "a")); binder.onClick(anchor).sort(foo).by(naturalComparator); assertThat(foo.get(), contains("b", "a")); anchor.click(); assertThat(foo.get(), contains("a", "b")); anchor.click(); assertThat(foo.get(), contains("b", "a")); }
@Test public void onClickMoveDown() { ListProperty<String> strings = listProperty("strings"); strings.set(list("a", "b")); binder.onClick(anchor).moveDown("a").in(strings); anchor.click(); assertThat(strings.get(), contains("b", "a")); }