@Test public void shownSuccessWhenUnset() { StubTextBox t = new StubTextBox(); assertThat(t, is(shown())); }
@Test public void invisibleFailureWhenUnset() { StubTextBox t = new StubTextBox(); try { assertThat(t, is(invisible())); fail(); } catch (AssertionError ae) { assertThat(ae.getMessage(), is("\nExpected: is invisible because visibility is \"hidden\"\n but: visibility was null")); } }
@Test public void hasStyleFailure() { StubTextBox t = new StubTextBox(); try { assertThat(t, hasStyle("a")); fail(); } catch (AssertionError ae) { assertThat(ae.getMessage(), is("\nExpected: style is a collection containing \"a\"\n but: style was \"\"")); } }
@Test public void hasNoStylesSuccess() { StubTextBox t = new StubTextBox(); assertThat(t, hasNoStyles()); }
@Test public void hasNoStylesFailure() { StubTextBox t = new StubTextBox(); t.addStyleName("a"); try { assertThat(t, hasNoStyles()); fail(); } catch (AssertionError ae) { assertThat(ae.getMessage(), is("\nExpected: style is an empty collection\n but: style was <[a]>")); } }
@Test public void visibleFailure() { StubTextBox t = new StubTextBox(); t.getStyle().setVisibility(Visibility.HIDDEN); try { assertThat(t, is(visible())); fail(); } catch (AssertionError ae) { assertThat(ae.getMessage(), is("\nExpected: is visible because visibility is not \"hidden\"\n but: visibility was \"hidden\"")); } }
@Test public void hiddenFailure() { StubTextBox t = new StubTextBox(); t.getStyle().setDisplay(Display.BLOCK); try { assertThat(t, is(hidden())); fail(); } catch (AssertionError ae) { assertThat(ae.getMessage(), is("\nExpected: is hidden because display is \"none\"\n but: display was \"block\"")); } }
@Test public void invisibleFailureWhenVisible() { StubTextBox t = new StubTextBox(); t.getStyle().setVisibility(Visibility.VISIBLE); try { assertThat(t, is(invisible())); fail(); } catch (AssertionError ae) { assertThat(ae.getMessage(), is("\nExpected: is invisible because visibility is \"hidden\"\n but: visibility was \"visible\"")); } } }
@Test public void shownFailureWhenDisplayNone() { StubTextBox t = new StubTextBox(); t.getStyle().setDisplay(Display.NONE); try { assertThat(t, is(shown())); fail(); } catch (AssertionError ae) { assertThat(ae.getMessage(), is("\nExpected: is showing because display is not \"none\"\n but: display was \"none\"")); } }
@Test public void hasCssValueFailure() { StubTextBox t = new StubTextBox(); t.getStyle().setColor("blue"); try { assertThat(t, hasCssValue("color", "red")); fail(); } catch (AssertionError ae) { assertThat(ae.getMessage(), is("\nExpected: color is \"red\"\n but: color was \"blue\"")); } }
@Test public void shownSuccessWhenDisplayBlock() { StubTextBox t = new StubTextBox(); t.getStyle().setDisplay(Display.BLOCK); assertThat(t, is(shown())); }
@Test public void hiddenSuccess() { StubTextBox t = new StubTextBox(); t.getStyle().setDisplay(Display.NONE); assertThat(t, is(hidden())); }
@Test public void debugId() { StubTextBox t = new StubTextBox(); TakesValue<String> id = TakesValues.debugId(t); id.setValue("foo"); assertThat(t.getIsElement().getAttribute("id"), is("foo")); assertThat(id.getValue(), is("foo")); }
@Test public void hasStyleSuccess() { StubTextBox t = new StubTextBox(); t.addStyleName("a"); t.addStyleName("b"); assertThat(t, hasStyle("a")); }
@Test public void hasCssValueSuccess() { StubTextBox t = new StubTextBox(); t.getStyle().setColor("blue"); assertThat(t, hasCssValue("color", "blue")); }
@Test public void testInsertDomInsertTrue() { StubTextBox b = new StubTextBox(); StubElement e = new StubElement(); p.insert(b, e, 0, true); assertThat(p.getIsWidget(0), is((IsWidget) b)); assertThat(p.getAddedTo(e).get(0), is((com.google.gwt.user.client.ui.IsWidget) b)); }
@Test public void testClear() { StubFlowPanel p = new StubFlowPanel(); p.add(new StubTextBox()); p.clear(); }
@Test public void testSettingInitialValueWhenBound() { IntegerProperty i = integerProperty("i"); Property<String> s = i.asString(); StubTextBox textBox = new StubTextBox(); Binder b = new Binder(); b.bind(s).to(textBox); i.setInitialValue(1); assertThat(i.isTouched(), is(false)); }
@Test public void enhanceIgnoresTabKeyUpEvent() { final StubTextBox b = new StubTextBox(); final StringProperty s = stringProperty("s"); binder.bind(s).to(b); binder.enhance(b); b.keyUp(KEY_TAB); assertThat(s.get(), is(nullValue())); }
@Test public void onKeyDownFiltered() { final StubTextBox b = new StubTextBox(); binder.onKeyDown(b, KeyCodes.KEY_ENTER).set(s).to("asdf"); b.keyDown('a'); assertThat(s.get(), is(nullValue())); b.keyDown(KeyCodes.KEY_ENTER); assertThat(s.get(), is("asdf")); }