use of com.google.gwt.user.client.ui.MenuItem in project gwt-test-utils by gwt-test-utils.
the class MenuBarTest method removeItem.
@Test
public void removeItem() {
// Given
MenuBar bar = new MenuBar();
MenuItem item0 = bar.addItem("test0", cmd);
MenuItem item1 = bar.addItem("test1", cmd);
// When
bar.removeItem(item0);
// Then
assertThat(bar.getItemIndex(item1)).isEqualTo(0);
}
use of com.google.gwt.user.client.ui.MenuItem in project gwt-test-utils by gwt-test-utils.
the class MenuBarTest method constructor_Complex.
@Test
public void constructor_Complex() {
// Given
MenuBar bar = new MenuBar();
MenuBar subMenuBar = new MenuBar();
MenuItem item = new MenuItem("item", false, subMenuBar);
bar.addItem(item);
item.setCommand(cmd);
// Preconditions
assertThat(called).isEqualTo(false);
// When
Browser.click(bar, item);
// Then
assertThat(called).isEqualTo(true);
}
use of com.google.gwt.user.client.ui.MenuItem in project gwt-test-utils by gwt-test-utils.
the class MenuBarTest method addItem.
@Test
public void addItem() {
// Given
MenuBar bar = new MenuBar();
// When
MenuItem item0 = bar.addItem("test0", cmd);
MenuItem item1 = bar.addItem("test1", cmd);
// Then
assertThat(bar.getItemIndex(item0)).isEqualTo(0);
assertThat(bar.getItemIndex(item1)).isEqualTo(1);
assertThat(item0.getParentMenu()).isEqualTo(bar);
assertThat(item1.getParentMenu()).isEqualTo(bar);
}
use of com.google.gwt.user.client.ui.MenuItem in project gwt-test-utils by gwt-test-utils.
the class MenuBarTest method click.
@Test
public void click() {
// Given
MenuBar bar = new MenuBar();
MenuItem item = bar.addItem("item", cmd);
// Preconditions
assertThat(called).isEqualTo(false);
// When
Browser.click(bar, item);
// Then
assertThat(called).isEqualTo(true);
}
use of com.google.gwt.user.client.ui.MenuItem in project rstudio by rstudio.
the class BaseMenuBar method onLoad.
@Override
protected void onLoad() {
if (vertical_ && glass++ == 0)
eventBus_.fireEvent(new GlassVisibilityEvent(true));
super.onLoad();
for (MenuItem child : getItems()) {
if (child instanceof AppMenuItem)
((AppMenuItem) child).onShow();
else {
// if this is a submenu that consists entirely of hidden commands,
// hide the submenu and its flyout icon
MenuBar submenu = child.getSubMenu();
if (submenu != null && submenu instanceof AppMenuBar) {
boolean visible = child.isVisible();
boolean newVisible = !((AppMenuBar) submenu).allInvisibleCmds();
if (visible != newVisible) {
child.setVisible(newVisible);
updateSubmenuIcon(child);
}
}
}
}
if (autoHideRedundantSeparators_)
manageSeparators();
}
Aggregations