com.googlecode.gwt.test.utils.WidgetUtils Maven / Gradle / Ivy
package com.googlecode.gwt.test.utils;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.InputElement;
import com.google.gwt.event.dom.client.DomEvent.Type;
import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.shared.EventHandler;
import com.google.gwt.event.shared.GwtEvent;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.EventListener;
import com.google.gwt.user.client.ui.*;
import com.google.gwt.user.client.ui.SuggestBox.SuggestionDisplay;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* Class which provides utilities on {@link Widget} classes.
*
* @author Gael Lazzari
*/
public class WidgetUtils {
public static boolean assertListBoxDataMatch(ListBox listBox, String[] content) {
int contentSize = content.length;
if (contentSize != listBox.getItemCount()) {
return false;
}
for (int i = 0; i < contentSize; i++) {
if (!content[i].equals(listBox.getItemText(i))) {
return false;
}
}
return true;
}
@SuppressWarnings("unchecked")
public static List getHandlers(Widget widget, Type eventType) {
HandlerManager handlerManager = GwtReflectionUtils.getPrivateFieldValue(widget,
"handlerManager");
Object handlerRegistry = GwtReflectionUtils.getPrivateFieldValue(handlerManager, "eventBus");
Map, Map