//
// This file is part of the Prose Development Tools for Eclipse package.
//
// The contents of this file are subject to the Mozilla Public License
// Version 1.1 (the "License"); you may not use this file except in
// compliance with the License. You may obtain a copy of the License at
// http://www.mozilla.org/MPL/
//
// Software distributed under the License is distributed on an "AS IS" basis,
// WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
// for the specific language governing rights and limitations under the
// License.
//
// The Original Code is Prose Development Tools for Eclipse.
//
// The Initial Developer of the Original Code is Angela Nicoara. Portions
// created by Angela Nicoara are Copyright (C) 2006 Angela Nicoara.
// All Rights Reserved.
//
// Contributor(s):
// $Id: ProseRunViewTest.java,v 1.1 2008/11/18 12:37:15 anicoara Exp $
// ==============================================================================
//
package ch.ethz.prose.eclipse.test;
import junit.framework.TestCase;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import ch.ethz.prose.eclipse.internal.core.ProsePlugin;
import ch.ethz.prose.eclipse.internal.run.ProseRunView;
/**
* @author Angela Nicoara
* @author Johann Gyger
* @version $Id: ProseRunViewTest.java,v 1.1 2008/11/18 12:37:15 anicoara Exp $
*/
public class ProseRunViewTest extends TestCase {
protected ProseRunView view;
protected IWorkbenchPage getPage() {
IWorkbench workbench = PlatformUI.getWorkbench();
IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
return window.getActivePage();
}
protected void showView() throws PartInitException {
view = (ProseRunView) getPage().showView("ch.ethz.prose.eclipse.ProseRunView");
}
protected void hideView() {
getPage().hideView(view);
}
/**
* Test if the view can be created, shown, and hidden.
*
* @throws PartInitException
*/
public void testShowHide() throws PartInitException {
showView();
hideView();
}
/**
* Test if the view registers an IProseRunListener.
*
* @throws PartInitException
*/
public void testViewListener() throws PartInitException {
int count = ProsePlugin.getDefault().getRunListeners().size();
showView();
try {
assertEquals(count + 1, ProsePlugin.getDefault().getRunListeners().size());
} finally {
hideView();
}
assertEquals(count, ProsePlugin.getDefault().getRunListeners().size());
}
}