public void testSelection() {
loadApi(new Runnable() {
public void run() {
GeoMap.Options options = GeoMap.Options.create();
final GeoMap viz = new GeoMap(createDataTable(), options);
// Add a selection handler
viz.addSelectHandler(new SelectHandler() {
@Override
public void onSelect(SelectEvent event) {
assertNotNull(event);
JsArray<Selection> s = viz.getSelections();
assertEquals("Expected 1 element in the selection", 1,
s.length());
assertEquals("Expected row 1 to be selected", 1, s.get(0).getRow());
assertEquals("Expected column 0 to be selected", 0, s.get(0).getColumn());
finishTest();
}
});
RootPanel.get().add(viz);
JsArray<Selection> s =
ArrayHelper.toJsArray(Selection.createCellSelection(1, 0));
assertEquals("Expected 1 element in the selection", 1, s.length());
assertEquals("Expected row 1 to be selected", 1, s.get(0).getRow());
assertEquals("Expected column 0 to be selected", 0, s.get(0).getColumn());
viz.setSelections(s);
s = viz.getSelections();
assertEquals("Expected 1 element in the selection", 1, s.length());
assertEquals("Expected row 1 to be selected", 1, s.get(0).getRow());
assertEquals("Expected column 0 to be selected", 0, s.get(0).getColumn());
// Trigger a selection callback
triggerSelection(viz, s);