@Test public void testSetupEventHandlers() { daysInput.value = "2"; hoursInput.value = "4"; minutesInput.value = "8"; secondsInput.value = "16"; when(daysInput.getAttribute("data-old")).thenReturn("getAttribute was invoked"); when(hoursInput.getAttribute("data-old")).thenReturn("getAttribute was invoked"); when(minutesInput.getAttribute("data-old")).thenReturn("getAttribute was invoked"); when(secondsInput.getAttribute("data-old")).thenReturn("getAttribute was invoked"); doNothing().when(daysInput).setAttribute("data-old", daysInput.value); doNothing().when(hoursInput).setAttribute("data-old", hoursInput.value); doNothing().when(minutesInput).setAttribute("data-old", minutesInput.value); doNothing().when(secondsInput).setAttribute("data-old", secondsInput.value); final OnchangeFn onChangeHandler = mock(OnchangeFn.class); doReturn(onChangeHandler).when(view).getOnChangeHandler(); daysInput.onchange = null; hoursInput.onchange = null; minutesInput.onchange = null; secondsInput.onchange = null; view.setupEventHandlers(); assertEquals(daysInput.onchange, onChangeHandler); assertEquals(hoursInput.onchange, onChangeHandler); assertEquals(minutesInput.onchange, onChangeHandler); assertEquals(secondsInput.onchange, onChangeHandler); MinMaxValueHelper.setupMinMaxHandlers(daysInput); daysInput.onfocusout.onInvoke(null); daysInput.onkeydown.onInvoke(null); daysInput.onkeyup.onInvoke(null); verify(daysInput).setAttribute("data-old", daysInput.value); verify(daysInput, times(2)).getAttribute("data-old"); MinMaxValueHelper.setupMinMaxHandlers(hoursInput); hoursInput.onfocusout.onInvoke(null); hoursInput.onkeydown.onInvoke(null); hoursInput.onkeyup.onInvoke(null); verify(hoursInput).setAttribute("data-old", hoursInput.value); verify(hoursInput, times(2)).getAttribute("data-old"); MinMaxValueHelper.setupMinMaxHandlers(minutesInput); minutesInput.onfocusout.onInvoke(null); minutesInput.onkeydown.onInvoke(null); minutesInput.onkeyup.onInvoke(null); verify(minutesInput).setAttribute("data-old", minutesInput.value); verify(minutesInput, times(2)).getAttribute("data-old"); MinMaxValueHelper.setupMinMaxHandlers(secondsInput); secondsInput.onfocusout.onInvoke(null); secondsInput.onkeydown.onInvoke(null); secondsInput.onkeyup.onInvoke(null); verify(secondsInput).setAttribute("data-old", secondsInput.value); verify(secondsInput, times(2)).getAttribute("data-old"); }
@PostConstruct public void setupEventHandlers() { setupMinMaxHandlers(daysInput); setupMinMaxHandlers(hoursInput); setupMinMaxHandlers(minutesInput); setupMinMaxHandlers(secondsInput); daysInput.onchange = getOnChangeHandler(); hoursInput.onchange = getOnChangeHandler(); minutesInput.onchange = getOnChangeHandler(); secondsInput.onchange = getOnChangeHandler(); }
DayTimeSelectorView implements DayTimeSelector.View { @PostConstruct public void setupEventHandlers() { setupMinMaxHandlers(daysInput); setupMinMaxHandlers(hoursInput); setupMinMaxHandlers(minutesInput); setupMinMaxHandlers(secondsInput); daysInput.onchange = getOnChangeHandler(); hoursInput.onchange = getOnChangeHandler(); minutesInput.onchange = getOnChangeHandler(); secondsInput.onchange = getOnChangeHandler(); } }
DayTimeSelectorView implements DayTimeSelector.View { @PostConstruct public void setupEventHandlers() { setupMinMaxHandlers(daysInput); setupMinMaxHandlers(hoursInput); setupMinMaxHandlers(minutesInput); setupMinMaxHandlers(secondsInput); daysInput.onchange = getOnChangeHandler(); hoursInput.onchange = getOnChangeHandler(); minutesInput.onchange = getOnChangeHandler(); secondsInput.onchange = getOnChangeHandler(); } @Inject  DayTimeSelectorView(final HTMLInputElement daysInput,
                               final HTMLInputElement hoursInput,
                               final HTMLInputElement minutesInput,
                               final HTMLInputElement secondsInput); }
DayTimeSelectorView implements DayTimeSelector.View { @PostConstruct public void setupEventHandlers() { setupMinMaxHandlers(daysInput); setupMinMaxHandlers(hoursInput); setupMinMaxHandlers(minutesInput); setupMinMaxHandlers(secondsInput); daysInput.onchange = getOnChangeHandler(); hoursInput.onchange = getOnChangeHandler(); minutesInput.onchange = getOnChangeHandler(); secondsInput.onchange = getOnChangeHandler(); } @Inject  DayTimeSelectorView(final HTMLInputElement daysInput,
                               final HTMLInputElement hoursInput,
                               final HTMLInputElement minutesInput,
                               final HTMLInputElement secondsInput); @Override void init(final DayTimeSelector presenter); @PostConstruct void setupEventHandlers(); @Override DayTimeValue getValue(); @Override void setValue(final DayTimeValue value); @Override void setOnValueChanged(final Consumer<Event> onValueChangedConsumer); @Override void setOnValueInputBlur(final Consumer<BlurEvent> onValueInputBlurConsumer); @EventHandler("days-input") void onDaysInputBlurEvent(final BlurEvent blurEvent); @EventHandler("hours-input") void onHoursInputBlurEvent(final BlurEvent blurEvent); @EventHandler("minutes-input") void onMinutesInputBlurEvent(final BlurEvent blurEvent); @EventHandler("seconds-input") void onSecondsInputBlurEvent(final BlurEvent blurEvent); @Override void select(); }
DayTimeSelectorView implements DayTimeSelector.View { @PostConstruct public void setupEventHandlers() { setupMinMaxHandlers(daysInput); setupMinMaxHandlers(hoursInput); setupMinMaxHandlers(minutesInput); setupMinMaxHandlers(secondsInput); daysInput.onchange = getOnChangeHandler(); hoursInput.onchange = getOnChangeHandler(); minutesInput.onchange = getOnChangeHandler(); secondsInput.onchange = getOnChangeHandler(); } @Inject  DayTimeSelectorView(final HTMLInputElement daysInput,
                               final HTMLInputElement hoursInput,
                               final HTMLInputElement minutesInput,
                               final HTMLInputElement secondsInput); @Override void init(final DayTimeSelector presenter); @PostConstruct void setupEventHandlers(); @Override DayTimeValue getValue(); @Override void setValue(final DayTimeValue value); @Override void setOnValueChanged(final Consumer<Event> onValueChangedConsumer); @Override void setOnValueInputBlur(final Consumer<BlurEvent> onValueInputBlurConsumer); @EventHandler("days-input") void onDaysInputBlurEvent(final BlurEvent blurEvent); @EventHandler("hours-input") void onHoursInputBlurEvent(final BlurEvent blurEvent); @EventHandler("minutes-input") void onMinutesInputBlurEvent(final BlurEvent blurEvent); @EventHandler("seconds-input") void onSecondsInputBlurEvent(final BlurEvent blurEvent); @Override void select();  }