mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-12 02:35:37 +02:00
Fix unwanted help provider issues and add help provider test to automated suite
This commit is contained in:
parent
0a0ac2396e
commit
026c8371f8
3 changed files with 43 additions and 9 deletions
|
@ -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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* 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.buildconsole.BuildConsoleTests;
|
||||||
import org.eclipse.cdt.ui.tests.callhierarchy.CallHierarchyTestSuite;
|
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.includebrowser.IncludeBrowserTestSuite;
|
||||||
import org.eclipse.cdt.ui.tests.refactoring.RefactoringTestSuite;
|
import org.eclipse.cdt.ui.tests.refactoring.RefactoringTestSuite;
|
||||||
import org.eclipse.cdt.ui.tests.search.SearchTestSuite;
|
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
|
// tests from package org.eclipse.cdt.ui.tests.refactoring
|
||||||
addTest(RefactoringTestSuite.suite());
|
addTest(RefactoringTestSuite.suite());
|
||||||
|
|
||||||
|
// tests from package org.eclipse.cdt.ui.tests.chelp
|
||||||
|
addTest(CHelpTest.suite());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -94,6 +94,18 @@ public class CHelpTest extends TestCase {
|
||||||
return new TestSuite(CHelpTest.class);
|
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(){
|
public void testCHelpProviderManagerGeneral(){
|
||||||
CHelpProviderManager mngr = CHelpProviderManager.getDefault();
|
CHelpProviderManager mngr = CHelpProviderManager.getDefault();
|
||||||
if(mngr == null)
|
if(mngr == null)
|
||||||
|
@ -131,7 +143,7 @@ public class CHelpTest extends TestCase {
|
||||||
|
|
||||||
public void testGetMatchingFunctions(){
|
public void testGetMatchingFunctions(){
|
||||||
if(!CHelpProviderTester.getDefault().onlyTestInfoProvidersAvailable()){
|
if(!CHelpProviderTester.getDefault().onlyTestInfoProvidersAvailable()){
|
||||||
//this test assumes that only CHelpTestInfoProviders are available
|
//this test assumes that only CHelpTestInfoProviders are available
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try{
|
try{
|
||||||
|
@ -152,7 +164,7 @@ public class CHelpTest extends TestCase {
|
||||||
|
|
||||||
public void testGetFunctionInfo(){
|
public void testGetFunctionInfo(){
|
||||||
if(!CHelpProviderTester.getDefault().onlyTestInfoProvidersAvailable()){
|
if(!CHelpProviderTester.getDefault().onlyTestInfoProvidersAvailable()){
|
||||||
//this test assumes that only CHelpTestInfoProviders are available
|
//this test assumes that only CHelpTestInfoProviders are available
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try{
|
try{
|
||||||
|
@ -173,7 +185,7 @@ public class CHelpTest extends TestCase {
|
||||||
|
|
||||||
public void testGetHelpResources(){
|
public void testGetHelpResources(){
|
||||||
if(!CHelpProviderTester.getDefault().onlyTestInfoProvidersAvailable()){
|
if(!CHelpProviderTester.getDefault().onlyTestInfoProvidersAvailable()){
|
||||||
//this test assumes that only CHelpTestInfoProviders are available
|
//this test assumes that only CHelpTestInfoProviders are available
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try{
|
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$
|
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);
|
j < cBookDescriptors.length || curBookDes.getCHelpBook().getCHelpType() == ICHelpBook.HELP_TYPE_CPP);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(CoreException e){
|
catch(CoreException e){
|
||||||
fail("CoreException occured: " + e.getMessage()); //$NON-NLS-1$
|
fail("CoreException occured: " + e.getMessage()); //$NON-NLS-1$
|
||||||
|
|
|
@ -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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Intel Corporation - Initial API and implementation
|
* Intel Corporation - Initial API and implementation
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
package org.eclipse.cdt.ui.tests.chelp;
|
package org.eclipse.cdt.ui.tests.chelp;
|
||||||
|
@ -26,11 +26,17 @@ public class CHelpTestInfoProvider implements ICHelpProvider {
|
||||||
private static int fNumProviders = 0;
|
private static int fNumProviders = 0;
|
||||||
private static final String PROVIDER_ID_PREFIX = "TestInfoProvider_";
|
private static final String PROVIDER_ID_PREFIX = "TestInfoProvider_";
|
||||||
|
|
||||||
final private String fProviderID;
|
final private String fProviderID;
|
||||||
private boolean fIsInitialized = false;
|
private boolean fIsInitialized = false;
|
||||||
|
|
||||||
private ICHelpBook fCHelpBooks[];
|
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(){
|
public CHelpTestInfoProvider(){
|
||||||
fProviderID = PROVIDER_ID_PREFIX + fNumProviders++;
|
fProviderID = PROVIDER_ID_PREFIX + fNumProviders++;
|
||||||
fCHelpBooks = CHelpProviderTester.getDefault().generateCHelpBooks(fProviderID);
|
fCHelpBooks = CHelpProviderTester.getDefault().generateCHelpBooks(fProviderID);
|
||||||
|
@ -52,6 +58,9 @@ public class CHelpTestInfoProvider implements ICHelpProvider {
|
||||||
* @see org.eclipse.cdt.ui.ICHelpProvider#getCHelpBooks()
|
* @see org.eclipse.cdt.ui.ICHelpProvider#getCHelpBooks()
|
||||||
*/
|
*/
|
||||||
public ICHelpBook[] getCHelpBooks() {
|
public ICHelpBook[] getCHelpBooks() {
|
||||||
|
if (!fgEnabled) {
|
||||||
|
return new ICHelpBook[0];
|
||||||
|
}
|
||||||
Assert.assertTrue("getCHelpBooks is called before completion contributor gets initialized",fIsInitialized);
|
Assert.assertTrue("getCHelpBooks is called before completion contributor gets initialized",fIsInitialized);
|
||||||
return fCHelpBooks;
|
return fCHelpBooks;
|
||||||
}
|
}
|
||||||
|
@ -61,6 +70,9 @@ public class CHelpTestInfoProvider implements ICHelpProvider {
|
||||||
*/
|
*/
|
||||||
public IFunctionSummary getFunctionInfo(ICHelpInvocationContext context,
|
public IFunctionSummary getFunctionInfo(ICHelpInvocationContext context,
|
||||||
ICHelpBook[] helpBooks, String name) {
|
ICHelpBook[] helpBooks, String name) {
|
||||||
|
if (!fgEnabled) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
Assert.assertTrue("getFunctionInfo is called before completion contributor gets initialized",fIsInitialized);
|
Assert.assertTrue("getFunctionInfo is called before completion contributor gets initialized",fIsInitialized);
|
||||||
return CHelpProviderTester.getDefault().generateFunctionInfo(helpBooks,name,fProviderID);
|
return CHelpProviderTester.getDefault().generateFunctionInfo(helpBooks,name,fProviderID);
|
||||||
}
|
}
|
||||||
|
@ -71,6 +83,9 @@ public class CHelpTestInfoProvider implements ICHelpProvider {
|
||||||
public IFunctionSummary[] getMatchingFunctions(
|
public IFunctionSummary[] getMatchingFunctions(
|
||||||
ICHelpInvocationContext context, ICHelpBook[] helpBooks,
|
ICHelpInvocationContext context, ICHelpBook[] helpBooks,
|
||||||
String prefix) {
|
String prefix) {
|
||||||
|
if (!fgEnabled) {
|
||||||
|
return new IFunctionSummary[0];
|
||||||
|
}
|
||||||
Assert.assertTrue("getMatchingFunctions is called before completion contributor gets initialized",fIsInitialized);
|
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 null; // TODO returning null until someone puts in a preference to control it.
|
||||||
//return CHelpProviderTester.getDefault().generateMatchingFunctions(helpBooks,prefix,fProviderID);
|
//return CHelpProviderTester.getDefault().generateMatchingFunctions(helpBooks,prefix,fProviderID);
|
||||||
|
@ -81,6 +96,9 @@ public class CHelpTestInfoProvider implements ICHelpProvider {
|
||||||
*/
|
*/
|
||||||
public ICHelpResourceDescriptor[] getHelpResources(
|
public ICHelpResourceDescriptor[] getHelpResources(
|
||||||
ICHelpInvocationContext context, ICHelpBook[] helpBooks, String name) {
|
ICHelpInvocationContext context, ICHelpBook[] helpBooks, String name) {
|
||||||
|
if (!fgEnabled) {
|
||||||
|
return new ICHelpResourceDescriptor[0];
|
||||||
|
}
|
||||||
Assert.assertTrue("getHelpResources is called before completion contributor gets initialized",fIsInitialized);
|
Assert.assertTrue("getHelpResources is called before completion contributor gets initialized",fIsInitialized);
|
||||||
return CHelpProviderTester.getDefault().generateHelpResources(helpBooks,name,fProviderID);
|
return CHelpProviderTester.getDefault().generateHelpResources(helpBooks,name,fProviderID);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue