diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/AutomatedSuite.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/AutomatedSuite.java index 98da9377358..464ae4c68f7 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/AutomatedSuite.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/AutomatedSuite.java @@ -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()); } } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/chelp/CHelpTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/chelp/CHelpTest.java index 2762263e06c..6adbbac3ac0 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/chelp/CHelpTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/chelp/CHelpTest.java @@ -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$ diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/chelp/CHelpTestInfoProvider.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/chelp/CHelpTestInfoProvider.java index db088acc51c..0b9ca24e2ab 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/chelp/CHelpTestInfoProvider.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/chelp/CHelpTestInfoProvider.java @@ -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 true 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); }