|
From: Dan C. <cor...@us...> - 2010-01-18 08:19:26
|
Update of /cvsroot/jcommander/plugins/org.jcommander.ui.tests/src/org/jcommander/ui/tests In directory sfp-cvsdas-3.v30.ch3.sourceforge.com:/tmp/cvs-serv29495/src/org/jcommander/ui/tests Added Files: JCommanderUITest.java Log Message: UI tests based on SWTBot. See ID: 2932702 --- NEW FILE: JCommanderUITest.java --- package org.jcommander.ui.tests; import static org.junit.Assert.assertTrue; import java.util.LinkedList; import java.util.List; import org.eclipse.core.runtime.ILogListener; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Platform; import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; import org.eclipse.swtbot.swt.finder.SWTBotAssert; import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; import org.eclipse.swtbot.swt.finder.widgets.SWTBotLabel; import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell; import org.eclipse.swtbot.swt.finder.widgets.SWTBotText; import org.jcommander.ui.filepanel.model.FileControlModel; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; @RunWith(SWTBotJunit4ClassRunner.class) public class JCommanderUITest { private static SWTWorkbenchBot bot; @BeforeClass public static void beforeClass() throws Exception { bot = new SWTWorkbenchBot(); } /** * The {@link FileControlModel#update()} sometimes throws an exception. * It seems to be some kind of threading problem or something. * * @throws Exception */ @Test public void fileControlModelUpdateException() throws Exception { final List<Throwable> exceptions = new LinkedList<Throwable>(); ILogListener listener = new ILogListener() { @Override public void logging(IStatus status, String plugin) { // TODO Auto-generated method stub Throwable exception = status.getException(); if(exception != null) { exceptions.add(exception); } } }; Platform.addLogListener(listener); try { bot.menu("File").menu("Open Directory URL...").click(); SWTBotShell shell = bot.shell("Open Directory URL"); shell.activate(); bot.comboBox(0).setText("file:////C:/"); bot.button("OK").click(); } finally { Platform.removeLogListener(listener); } // No exception should be thrown assertTrue(exceptions.isEmpty()); SWTBotText currentDirectoryLabel = bot.text("C:\\"); SWTBotAssert.assertText("C:\\", currentDirectoryLabel); } @AfterClass public static void sleep() { bot.sleep(2000); } } |