blob: c2fdf44cc81c39928a90d158bd0c98a7c0099864 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2004, 2005 IBM Corporation 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:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.ui.tests.dynamicplugins;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jface.preference.IPreferenceNode;
import org.eclipse.ui.internal.IWorkbenchConstants;
import org.eclipse.ui.internal.dialogs.PropertyPageContributorManager;
import org.eclipse.ui.internal.dialogs.PropertyPageManager;
/**
* @since 3.1
*/
public class PropertyPageTests extends DynamicTestCase {
private static final String PROPERTYPAGE = "dynamicPropertyPage1";
/**
* @param testName
*/
public PropertyPageTests(String testName) {
super(testName);
}
public void testPropertyPageCount() {
PropertyPageContributorManager manager = PropertyPageContributorManager.getManager();
int size = manager.getContributors().size();
getBundle();
assertEquals(size + 1, manager.getContributors().size());
removeBundle();
assertEquals(size, manager.getContributors().size());
}
public void testPropertyPageContribution() {
PropertyPageContributorManager cManager = PropertyPageContributorManager.getManager();
PropertyPageManager manager;
IAdaptable adaptable = new IAdaptable() {
/* (non-Javadoc)
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
*/
public Object getAdapter(Class adapter) {
if (adapter == Object.class)
return this;
return null;
}};
cManager.contribute(manager = new PropertyPageManager(), adaptable);
assertNull(manager.find(PROPERTYPAGE));
getBundle();
cManager.contribute(manager = new PropertyPageManager(), adaptable);
IPreferenceNode result = manager.find(PROPERTYPAGE);
assertNotNull(result);
result.createPage(); // muck around and ensure we've created some potential garbage
result.disposeResources();
removeBundle();
cManager.contribute(manager = new PropertyPageManager(), adaptable);
assertNull(manager.find(PROPERTYPAGE));
}
/* (non-Javadoc)
* @see org.eclipse.ui.tests.dynamicplugins.DynamicTestCase#getExtensionId()
*/
protected String getExtensionId() {
return "newPropertyPage1.testDynamicPropertyPageAddition";
}
/* (non-Javadoc)
* @see org.eclipse.ui.tests.dynamicplugins.DynamicTestCase#getExtensionPoint()
*/
protected String getExtensionPoint() {
return IWorkbenchConstants.PL_PROPERTY_PAGES;
}
/* (non-Javadoc)
* @see org.eclipse.ui.tests.dynamicplugins.DynamicTestCase#getInstallLocation()
*/
protected String getInstallLocation() {
return "data/org.eclipse.newPropertyPage1";
}
/* (non-Javadoc)
* @see org.eclipse.ui.tests.dynamicplugins.DynamicTestCase#getMarkerClass()
*/
protected String getMarkerClass() {
return "org.eclipse.ui.dynamic.DynamicPropertyPage";
}
}