Package org.eclipse.swtbot.swt.finder.finders

Source Code of org.eclipse.swtbot.swt.finder.finders.MenuFinderTest

/*******************************************************************************
* 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
*******************************************************************************/
package org.eclipse.swtbot.swt.finder.finders;

import static org.eclipse.swtbot.swt.finder.SWTBotTestCase.assertText;
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.SWT;
import org.eclipse.swt.SWTException;
import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swtbot.swt.finder.test.AbstractMenuExampleTest;
import org.junit.Test;

/**
* @author Ketan Padegaonkar <KetanPadegaonkar [at] gmail [dot] com>
* @version $Id$
*/
public class MenuFinderTest extends AbstractMenuExampleTest {

  @Test
  public void clicksMenuItem() throws Exception {
    List<MenuItem> findControls = menuFinder.findMenus(any(MenuItem.class));
    MenuItem menuItem = findControls.get(1);
    try {
      menuItem.notifyListeners(SWT.Selection, null);
      fail("Expecting an SWTException");
    } catch (SWTException e) {
      pass();
    }
    assertText("&New Contact...  Ctrl+N", menuItem);
  }

  @Test
  public void findsAllVisibleMenus() throws Exception {
    List<MenuItem> findControls = menuFinder.findMenus(any(MenuItem.class));
    assertEquals(25, findControls.size());
    assertText("&Find...\tCtrl+F", findControls.get(21));
  }

}
TOP

Related Classes of org.eclipse.swtbot.swt.finder.finders.MenuFinderTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.