blob: 2ad37b7dd469fe1827605dbe30dbd7d9f5e224f9 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2008 Ketan Padegaonkar and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Ketan Padegaonkar - initial API and implementation
* Ketan Padegaonkar - http://swtbot.org/bugzilla/show_bug.cgi?id=88
*******************************************************************************/
package org.eclipse.swtbot.swt.finder.widgets;
import static org.eclipse.swtbot.swt.finder.SWTBotTestCase.assertNotSameWidget;
import static org.eclipse.swtbot.swt.finder.SWTBotTestCase.assertTextContains;
import static org.eclipse.swtbot.swt.finder.SWTBotTestCase.pass;
import static org.hamcrest.Matchers.any;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import java.util.List;
import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
import org.eclipse.swtbot.swt.finder.test.AbstractControlExampleTest;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
/**
* @author Ketan Padegaonkar <KetanPadegaonkar [at] gmail [dot] com>
* @version $Id$
*/
public class SWTBotToolbarDropDownButtonTest extends AbstractControlExampleTest {
@Test
public void findsToolBarButtonWithIndex() throws Exception {
SWTBotToolbarDropDownButton button0 = bot.toolbarDropDownButton("Drop Down");
SWTBotToolbarDropDownButton button1 = bot.toolbarDropDownButton("Drop Down", 1);
assertNotSameWidget(button0.widget, button1.widget);
}
@Test
public void clicksToolBarButton() throws Exception {
try {
bot.checkBox("Listen").select();
SWTBotToolbarDropDownButton button = bot.toolbarDropDownButton("Drop Down");
button.click();
assertTextContains("Selection [13]: SelectionEvent{ToolItem ", bot.textInGroup("Listeners").widget);
} finally {
bot.checkBox("Listen").deselect();
}
}
@Test
@Ignore("Broken on cocoa")
public void getsAllMenuItems() throws Exception {
List<? extends SWTBotMenu> menuItems = bot.toolbarDropDownButton("Drop Down").menuItems(any(MenuItem.class));
menuItems.get(0).click();
assertEquals(7, menuItems.size());
}
@Test
@Ignore
public void clicksADropDownMenuItem() throws Exception {
SWTBotToolbarDropDownButton button = bot.toolbarDropDownButton("Drop Down");
try {
bot.menu("Kiwi");
fail("The menu item should not exist");
} catch (WidgetNotFoundException e) {
pass();
}
bot.shell("SWT Controls").activate();
button.menuItem("Kiwi").click();
}
@Before
public void prepareExample() throws Exception {
bot.tabItem("ToolBar").activate();
}
}