mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-19 14:15:50 +02:00
[170429] applied patch for test subsystem test from Tobias Schwarz (WRS)
This commit is contained in:
parent
da623f63a7
commit
cab7dd53f2
3 changed files with 159 additions and 0 deletions
|
@ -17,6 +17,7 @@ import org.eclipse.rse.tests.core.connection.RSEConnectionTestSuite;
|
||||||
import org.eclipse.rse.tests.framework.DelegatingTestSuiteHolder;
|
import org.eclipse.rse.tests.framework.DelegatingTestSuiteHolder;
|
||||||
import org.eclipse.rse.tests.internal.RSEInternalFrameworkTestSuite;
|
import org.eclipse.rse.tests.internal.RSEInternalFrameworkTestSuite;
|
||||||
import org.eclipse.rse.tests.subsystems.files.RSEFileSubsystemTestSuite;
|
import org.eclipse.rse.tests.subsystems.files.RSEFileSubsystemTestSuite;
|
||||||
|
import org.eclipse.rse.tests.subsystems.testsubsystem.RSETestSubsystemTestSuite;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Main class bundling all single specialized test suites into a
|
* Main class bundling all single specialized test suites into a
|
||||||
|
@ -52,6 +53,7 @@ public class RSECombinedTestSuite extends DelegatingTestSuiteHolder {
|
||||||
suite.addTest(RSEInternalFrameworkTestSuite.suite());
|
suite.addTest(RSEInternalFrameworkTestSuite.suite());
|
||||||
suite.addTest(RSEConnectionTestSuite.suite());
|
suite.addTest(RSEConnectionTestSuite.suite());
|
||||||
suite.addTest(RSEFileSubsystemTestSuite.suite());
|
suite.addTest(RSEFileSubsystemTestSuite.suite());
|
||||||
|
suite.addTest(RSETestSubsystemTestSuite.suite());
|
||||||
|
|
||||||
return suite;
|
return suite;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,55 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2006 Wind River Systems, Inc. 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:
|
||||||
|
* Tobias Schwarz (Wind River) - initial API and implementation.
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.rse.tests.subsystems.testsubsystem;
|
||||||
|
|
||||||
|
import junit.framework.Test;
|
||||||
|
import junit.framework.TestSuite;
|
||||||
|
|
||||||
|
import org.eclipse.rse.tests.framework.DelegatingTestSuiteHolder;
|
||||||
|
|
||||||
|
public class RSETestSubsystemTestSuite extends DelegatingTestSuiteHolder {
|
||||||
|
/**
|
||||||
|
* Standard Java application main method. Allows to launch the test
|
||||||
|
* suite from outside as part of nightly runs, headless runs or other.
|
||||||
|
* <p><b>Note:</b> Use only <code>junit.textui.TestRunner</code> here as
|
||||||
|
* it is explicitly supposed to output the test output to the shell the
|
||||||
|
* test suite has been launched from.
|
||||||
|
* <p>
|
||||||
|
* @param args The standard Java application command line parameters passed in.
|
||||||
|
*/
|
||||||
|
public static void main(String[] args) {
|
||||||
|
junit.textui.TestRunner.run(suite());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Combine all test into a suite and returns the test suite instance.
|
||||||
|
* <p>
|
||||||
|
* <b>Note: This method must be always called <i><code>suite</code></i> ! Otherwise
|
||||||
|
* the JUnit plug-in test launcher will fail to detect this class!</b>
|
||||||
|
* <p>
|
||||||
|
* @return The test suite instance.
|
||||||
|
*/
|
||||||
|
public static Test suite() {
|
||||||
|
TestSuite suite = new TestSuite("RSE Test Subsystem Test Suite"); //$NON-NLS-1$
|
||||||
|
// add the single test suites to the overall one here.
|
||||||
|
suite.addTestSuite(TestSubsystemTestCase.class);
|
||||||
|
|
||||||
|
return suite;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.rse.tests.framework.AbstractTestSuiteHolder#getTestSuite()
|
||||||
|
*/
|
||||||
|
public TestSuite getTestSuite() {
|
||||||
|
return (TestSuite)RSETestSubsystemTestSuite.suite();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,102 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2006 Wind River Systems, Inc. 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:
|
||||||
|
* Tobias Schwarz (Wind River) - initial API and implementation.
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.rse.tests.subsystems.testsubsystem;
|
||||||
|
|
||||||
|
import org.eclipse.jface.viewers.AbstractTreeViewer;
|
||||||
|
import org.eclipse.jface.viewers.ISelection;
|
||||||
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||||
|
import org.eclipse.jface.viewers.StructuredSelection;
|
||||||
|
import org.eclipse.rse.core.SystemPerspectiveHelpers;
|
||||||
|
import org.eclipse.rse.core.model.IHost;
|
||||||
|
import org.eclipse.rse.tests.RSETestsPlugin;
|
||||||
|
import org.eclipse.rse.tests.core.RSEWaitAndDispatchUtil;
|
||||||
|
import org.eclipse.rse.tests.core.connection.RSEBaseConnectionTestCase;
|
||||||
|
import org.eclipse.rse.tests.testsubsystem.TestSubSystemContainerNode;
|
||||||
|
import org.eclipse.rse.tests.testsubsystem.interfaces.ITestSubSystem;
|
||||||
|
|
||||||
|
public class TestSubsystemTestCase extends RSEBaseConnectionTestCase {
|
||||||
|
private ITestSubSystem testSubSystem;
|
||||||
|
|
||||||
|
public void testAddAndDeleteDeepNodes() {
|
||||||
|
if (!RSETestsPlugin.isTestCaseEnabled("TestSubsystemTestCase.testAddAndDeleteDeepNodes")) return; //$NON-NLS-1$
|
||||||
|
testAddAndDeleteNodes(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testAddAndDeleteFlatNodes() {
|
||||||
|
if (!RSETestsPlugin.isTestCaseEnabled("TestSubsystemTestCase.testAddAndDeleteFlatNodes")) return; //$NON-NLS-1$
|
||||||
|
testAddAndDeleteNodes(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testAddAndDeleteNodes(boolean deep) {
|
||||||
|
IHost connection = getLocalSystemConnection();
|
||||||
|
assertNotNull("Failed to get local system connection", connection); //$NON-NLS-1$
|
||||||
|
|
||||||
|
Exception exception = null;
|
||||||
|
String cause = null;
|
||||||
|
|
||||||
|
testSubSystem = null;
|
||||||
|
try {
|
||||||
|
testSubSystem = getConnectionManager().getTestSubSystem(connection);
|
||||||
|
} catch(Exception e) {
|
||||||
|
exception = e;
|
||||||
|
cause = e.getLocalizedMessage();
|
||||||
|
}
|
||||||
|
assertNull("Failed to get test subsystem! Possible cause: " + cause, exception); //$NON-NLS-1$
|
||||||
|
assertNotNull("No test subystem", testSubSystem); //$NON-NLS-1$
|
||||||
|
|
||||||
|
testSubSystem.removeAllChildNodes();
|
||||||
|
|
||||||
|
TestSubSystemContainerNode firstNode = null;
|
||||||
|
TestSubSystemContainerNode node = null;
|
||||||
|
for (int i=0; i<100; i++) {
|
||||||
|
if (node == null) {
|
||||||
|
node = new TestSubSystemContainerNode("node "+i); //$NON-NLS-1$
|
||||||
|
firstNode = node;
|
||||||
|
testSubSystem.addChildNode(node);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
TestSubSystemContainerNode parentNode = node;
|
||||||
|
node = new TestSubSystemContainerNode("node "+i); //$NON-NLS-1$
|
||||||
|
if (deep) {
|
||||||
|
parentNode.addChildNode(node);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
testSubSystem.addChildNode(node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SystemPerspectiveHelpers.findRSEView().refresh(testSubSystem);
|
||||||
|
SystemPerspectiveHelpers.findRSEView().expandToLevel(testSubSystem, AbstractTreeViewer.ALL_LEVELS);
|
||||||
|
RSEWaitAndDispatchUtil.waitAndDispatch(1000);
|
||||||
|
|
||||||
|
SystemPerspectiveHelpers.findRSEView().setSelection(new StructuredSelection(node));
|
||||||
|
|
||||||
|
ISelection selection = SystemPerspectiveHelpers.findRSEView().getSelection();
|
||||||
|
assertTrue("missing selection", selection != null); //$NON-NLS-1$
|
||||||
|
assertTrue("not a structured selection", selection instanceof IStructuredSelection); //$NON-NLS-1$
|
||||||
|
IStructuredSelection structSel = (IStructuredSelection)selection;
|
||||||
|
assertEquals("invalid number of selected items", 1, structSel.size()); //$NON-NLS-1$
|
||||||
|
assertEquals("wrong item selected", node, structSel.getFirstElement()); //$NON-NLS-1$
|
||||||
|
|
||||||
|
testSubSystem.removeAllChildNodes();
|
||||||
|
|
||||||
|
SystemPerspectiveHelpers.findRSEView().refresh(testSubSystem);
|
||||||
|
RSEWaitAndDispatchUtil.waitAndDispatch(1000);
|
||||||
|
|
||||||
|
SystemPerspectiveHelpers.findRSEView().setSelection(new StructuredSelection(firstNode));
|
||||||
|
|
||||||
|
selection = SystemPerspectiveHelpers.findRSEView().getSelection();
|
||||||
|
assertTrue("missing selection", selection != null); //$NON-NLS-1$
|
||||||
|
assertTrue("not a structured selection", selection instanceof IStructuredSelection); //$NON-NLS-1$
|
||||||
|
structSel = (IStructuredSelection)selection;
|
||||||
|
assertEquals("invalid number of selected items", 0, structSel.size()); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue