}
public void testLinkTraversal() {
final String testHistoryToken = TEST_HISTORY_TOKEN;
Hyperlink link = new Hyperlink("foobar", testHistoryToken);
HandlerRegistration registration = null;
try {
RootPanel.get().add(link);
registration = History.addValueChangeHandler(new ValueChangeHandler<String>() {
@Override
public void onValueChange(ValueChangeEvent<String> event) {
assertEquals(testHistoryToken, event.getValue());
assertEquals(testHistoryToken, History.getToken());
}
});
Document document = Document.get();
NativeEvent event = document.createClickEvent(1, 0, 0, 0, 0, false, false, false, false);
link.getElement().dispatchEvent(event);
} finally {
RootPanel.get().remove(link);
if (registration != null) {
registration.removeHandler();
}
}
}