1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-11 18:25:40 +02:00

Fix unwanted help provider issues and add help provider test to automated suite

This commit is contained in:
Anton Leherbauer 2008-04-11 09:02:47 +00:00
parent 0a0ac2396e
commit 026c8371f8
3 changed files with 43 additions and 9 deletions

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2007 IBM Corporation and others.
* Copyright (c) 2000, 2008 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
@ -17,6 +17,7 @@ import junit.framework.TestSuite;
import org.eclipse.cdt.ui.tests.buildconsole.BuildConsoleTests;
import org.eclipse.cdt.ui.tests.callhierarchy.CallHierarchyTestSuite;
import org.eclipse.cdt.ui.tests.chelp.CHelpTest;
import org.eclipse.cdt.ui.tests.includebrowser.IncludeBrowserTestSuite;
import org.eclipse.cdt.ui.tests.refactoring.RefactoringTestSuite;
import org.eclipse.cdt.ui.tests.search.SearchTestSuite;
@ -77,6 +78,9 @@ public class AutomatedSuite extends TestSuite {
// tests from package org.eclipse.cdt.ui.tests.refactoring
addTest(RefactoringTestSuite.suite());
// tests from package org.eclipse.cdt.ui.tests.chelp
addTest(CHelpTest.suite());
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2004, 2006 Intel Corporation and others.
* Copyright (c) 2004, 2008 Intel 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
@ -94,6 +94,18 @@ public class CHelpTest extends TestCase {
return new TestSuite(CHelpTest.class);
}
@Override
protected void setUp() throws Exception {
super.setUp();
CHelpTestInfoProvider.fgEnabled= true;
}
@Override
protected void tearDown() throws Exception {
CHelpTestInfoProvider.fgEnabled= false;
super.tearDown();
}
public void testCHelpProviderManagerGeneral(){
CHelpProviderManager mngr = CHelpProviderManager.getDefault();
if(mngr == null)
@ -131,7 +143,7 @@ public class CHelpTest extends TestCase {
public void testGetMatchingFunctions(){
if(!CHelpProviderTester.getDefault().onlyTestInfoProvidersAvailable()){
//this test assumes that only CHelpTestInfoProviders are available
//this test assumes that only CHelpTestInfoProviders are available
return;
}
try{
@ -152,7 +164,7 @@ public class CHelpTest extends TestCase {
public void testGetFunctionInfo(){
if(!CHelpProviderTester.getDefault().onlyTestInfoProvidersAvailable()){
//this test assumes that only CHelpTestInfoProviders are available
//this test assumes that only CHelpTestInfoProviders are available
return;
}
try{
@ -173,7 +185,7 @@ public class CHelpTest extends TestCase {
public void testGetHelpResources(){
if(!CHelpProviderTester.getDefault().onlyTestInfoProvidersAvailable()){
//this test assumes that only CHelpTestInfoProviders are available
//this test assumes that only CHelpTestInfoProviders are available
return;
}
try{
@ -223,7 +235,7 @@ public class CHelpTest extends TestCase {
}
assertTrue("book \"" + curBookDes.getCHelpBook().getTitle() + "\" of type HELP_TYPE_C was not found in C books", //$NON-NLS-1$ //$NON-NLS-2$
j < cBookDescriptors.length || curBookDes.getCHelpBook().getCHelpType() == ICHelpBook.HELP_TYPE_CPP);
}
}
}
catch(CoreException e){
fail("CoreException occured: " + e.getMessage()); //$NON-NLS-1$

View file

@ -1,11 +1,11 @@
/**********************************************************************
* Copyright (c) 2004, 2005 Intel Corporation and others.
* Copyright (c) 2004, 2008 Intel 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:
* Contributors:
* Intel Corporation - Initial API and implementation
**********************************************************************/
package org.eclipse.cdt.ui.tests.chelp;
@ -26,11 +26,17 @@ public class CHelpTestInfoProvider implements ICHelpProvider {
private static int fNumProviders = 0;
private static final String PROVIDER_ID_PREFIX = "TestInfoProvider_";
final private String fProviderID;
final private String fProviderID;
private boolean fIsInitialized = false;
private ICHelpBook fCHelpBooks[];
/**
* Flag indicating whether this help provider should provide help info.
* Should be set to <code>true</code> during tests only.
*/
static boolean fgEnabled= false;
public CHelpTestInfoProvider(){
fProviderID = PROVIDER_ID_PREFIX + fNumProviders++;
fCHelpBooks = CHelpProviderTester.getDefault().generateCHelpBooks(fProviderID);
@ -52,6 +58,9 @@ public class CHelpTestInfoProvider implements ICHelpProvider {
* @see org.eclipse.cdt.ui.ICHelpProvider#getCHelpBooks()
*/
public ICHelpBook[] getCHelpBooks() {
if (!fgEnabled) {
return new ICHelpBook[0];
}
Assert.assertTrue("getCHelpBooks is called before completion contributor gets initialized",fIsInitialized);
return fCHelpBooks;
}
@ -61,6 +70,9 @@ public class CHelpTestInfoProvider implements ICHelpProvider {
*/
public IFunctionSummary getFunctionInfo(ICHelpInvocationContext context,
ICHelpBook[] helpBooks, String name) {
if (!fgEnabled) {
return null;
}
Assert.assertTrue("getFunctionInfo is called before completion contributor gets initialized",fIsInitialized);
return CHelpProviderTester.getDefault().generateFunctionInfo(helpBooks,name,fProviderID);
}
@ -71,6 +83,9 @@ public class CHelpTestInfoProvider implements ICHelpProvider {
public IFunctionSummary[] getMatchingFunctions(
ICHelpInvocationContext context, ICHelpBook[] helpBooks,
String prefix) {
if (!fgEnabled) {
return new IFunctionSummary[0];
}
Assert.assertTrue("getMatchingFunctions is called before completion contributor gets initialized",fIsInitialized);
return null; // TODO returning null until someone puts in a preference to control it.
//return CHelpProviderTester.getDefault().generateMatchingFunctions(helpBooks,prefix,fProviderID);
@ -81,6 +96,9 @@ public class CHelpTestInfoProvider implements ICHelpProvider {
*/
public ICHelpResourceDescriptor[] getHelpResources(
ICHelpInvocationContext context, ICHelpBook[] helpBooks, String name) {
if (!fgEnabled) {
return new ICHelpResourceDescriptor[0];
}
Assert.assertTrue("getHelpResources is called before completion contributor gets initialized",fIsInitialized);
return CHelpProviderTester.getDefault().generateHelpResources(helpBooks,name,fProviderID);
}