*/
@After
public void tearDown() {
- fFacility.waitForJobs();
+ fFacility.dispose();
}
/**
fProxy.setTestFile(fTestFile);
fProxy.setScenario(TraceControlTestFacility.SCEN_INIT_TEST);
- ITraceControlComponent root = TraceControlTestFacility.getInstance().getControlView().getTraceControlRoot();
+ ITraceControlComponent root = fFacility.getControlView().getTraceControlRoot();
TargetNodeComponent node = new TargetNodeComponent("myNode", root, fProxy);
*/
@After
public void tearDown() {
- fFacility.waitForJobs();
fFacility.dispose();
}
*/
@After
public void tearDown() {
- fFacility.waitForJobs();
fFacility.dispose();
}
import org.eclipse.tracecompass.tmf.remote.core.proxy.TmfRemoteConnectionFactory;
import org.eclipse.ui.views.properties.IPropertySource;
import org.junit.After;
+import org.junit.Before;
import org.junit.Test;
import org.osgi.framework.FrameworkUtil;
// Constants
// ------------------------------------------------------------------------
+ private TraceControlTestFacility fFacility;
private static final String DIRECTORY = "testfiles";
private static final String TEST_STREAM = "ListInfoTest.cfg";
private static final String SCEN_LIST_INFO_TEST = "ListInfoTest";
// Housekeeping
// ------------------------------------------------------------------------
+ /**
+ * Perform pre-test initialization.
+ */
+ @Before
+ public void setUp() {
+ fFacility = TraceControlTestFacility.getInstance();
+ fFacility.init();
+ }
+
/**
* Perform post-test clean-up.
*/
@After
public void tearDown() {
- TraceControlTestFacility.getInstance().waitForJobs();
+ fFacility.dispose();
}
/**
proxy.setTestFile(testfile.getAbsolutePath());
proxy.setScenario(SCEN_LIST_INFO_TEST);
- ITraceControlComponent root = TraceControlTestFacility.getInstance().getControlView().getTraceControlRoot();
+ ITraceControlComponent root = fFacility.getControlView().getTraceControlRoot();
TargetNodeComponent node = new TargetNodeComponent("myNode", root, proxy);
root.addChild(node);
node.connect();
- TraceControlTestFacility.getInstance().waitForConnect(node);
- TraceControlTestFacility.getInstance().waitForJobs();
+ fFacility.waitForConnect(node);
+ fFacility.waitForJobs();
// ------------------------------------------------------------------------
// Verify Node Properties (adapter)
*/
@After
public void tearDown() {
- fFacility.waitForJobs();
fFacility.dispose();
}
//-------------------------------------------------------------------------
fFacility.executeCommand(node, "delete");
-
- assertEquals(0,fFacility.getControlView().getTraceControlRoot().getChildren().length);
}
}
\ No newline at end of file
package org.eclipse.tracecompass.lttng2.control.ui.tests.model.component;
+import static org.junit.Assert.assertNotNull;
+
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.commands.NotEnabledException;
import org.eclipse.core.commands.NotHandledException;
// ------------------------------------------------------------------------
private static TraceControlTestFacility fInstance = null;
private ControlView fControlView = null;
- private boolean fIsInitialized = false;
+ private volatile boolean fIsInitialized = false;
// ------------------------------------------------------------------------
// Constructors
public void init() {
if (!fIsInitialized) {
-
IViewPart view;
try {
-
- view = PlatformUI.getWorkbench()
- .getActiveWorkbenchWindow()
- .getActivePage()
- .findView("org.eclipse.ui.internal.introview");
-
- if (view != null) {
- PlatformUI.getWorkbench()
- .getActiveWorkbenchWindow()
- .getActivePage().hideView(view);
- }
-
- view = PlatformUI.getWorkbench()
- .getActiveWorkbenchWindow()
- .getActivePage()
- .showView(ControlView.ID);
-
+ hideView("org.eclipse.ui.internal.introview");
+ view = showView(ControlView.ID);
} catch (PartInitException e) {
throw new RuntimeException(e);
}
-
fControlView = (ControlView) view;
/*
*/
fControlView.getTraceControlRoot().removeAllChildren();
- delay(3000);
fIsInitialized = true;
}
}
-
/**
* Disposes the facility (and GUI)
*/
public void dispose() {
if (fIsInitialized) {
waitForJobs();
-
- PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().hideView(fControlView);
+ hideView(ControlView.ID);
+ delay(200);
fIsInitialized = false;
}
}
}
}
+ /**
+ * Waits for a view to be closed
+ */
+ public void waitForViewClosed(String viewId) {
+ for (int i = 1; i < 5000 && (getViewPart(viewId) != null); i *= 2) {
+ delay(i);
+ }
+ }
+
+ /**
+ * Waits for a view to be closed
+ */
+ public void waitForViewOpend(String viewId) {
+ for (int i = 1; i < 5000 && (getViewPart(viewId) == null); i *= 2) {
+ delay(i);
+ }
+ }
+
/**
* Waits for all Eclipse jobs to finish
*/
}
}
+ private IViewPart showView(String viewId) throws PartInitException {
+ IViewPart view = getViewPart(viewId);
+
+ if (view == null) {
+ view = PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow()
+ .getActivePage().showView(viewId);
+
+ waitForViewOpend(viewId);
+ }
+ assertNotNull(view);
+ return view;
+ }
+
+ private void hideView(String viewId) {
+ IViewPart view = getViewPart(viewId);
+ if (view != null) {
+ PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow()
+ .getActivePage().hideView(view);
+ }
+ waitForViewClosed(viewId);
+ }
+
+ private static IViewPart getViewPart(String viewId) {
+ return PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow()
+ .getActivePage()
+ .findView(viewId);
+ }
+
/**
* @return current control view
*/
// ------------------------------------------------------------------------
// Test data
// ------------------------------------------------------------------------
-
+ private TraceControlTestFacility fFacility;
private IRemoteConnection fHost = TmfRemoteConnectionFactory.getLocalConnection();
private @NonNull TestRemoteSystemProxy fProxy = new TestRemoteSystemProxy(fHost);
private String fTestFile;
*/
@Before
public void setUp() throws Exception {
+ fFacility = TraceControlTestFacility.getInstance();
+ fFacility.init();
URL location = FileLocator.find(FrameworkUtil.getBundle(this.getClass()), new Path(TraceControlTestFacility.DIRECTORY + File.separator + TEST_STREAM), null);
File testfile = new File(FileLocator.toFileURL(location).toURI());
fTestFile = testfile.getAbsolutePath();
*/
@After
public void tearDown() {
- TraceControlTestFacility.getInstance().waitForJobs();
+ fFacility.dispose();
}
/**
fProxy.setTestFile(fTestFile);
fProxy.setScenario(SCEN_LIST_INFO_TEST);
- ITraceControlComponent root = TraceControlTestFacility.getInstance().getControlView().getTraceControlRoot();
+ ITraceControlComponent root = fFacility.getControlView().getTraceControlRoot();
TargetNodeComponent node = new TargetNodeComponent(TARGET_NODE_NAME, root, fProxy);
root.addChild(node);
node.connect();
- TraceControlTestFacility.getInstance().waitForConnect(node);
- TraceControlTestFacility.getInstance().waitForJobs();
+ fFacility.waitForConnect(node);
+ fFacility.waitForJobs();
// ------------------------------------------------------------------------
// Verify Parameters of TargetNodeComponent
// ------------------------------------------------------------------------
// Constants
// ------------------------------------------------------------------------
+ private TraceControlTestFacility fFacility;
private static final String TEST_STREAM = "ListInfoTest.cfg";
private static final String SCEN_LIST_INFO_TEST = "ListInfoTest";
*/
@Before
public void setUp() throws Exception {
+ fFacility = TraceControlTestFacility.getInstance();
+ fFacility.init();
URL location = FileLocator.find(FrameworkUtil.getBundle(this.getClass()), new Path(TraceControlTestFacility.DIRECTORY + File.separator + TEST_STREAM), null);
File testfile = new File(FileLocator.toFileURL(location).toURI());
fTestFile = testfile.getAbsolutePath();
*/
@After
public void tearDown() {
- TraceControlTestFacility.getInstance().waitForJobs();
+ fFacility.dispose();
}
/**
fProxy.setTestFile(fTestFile);
fProxy.setScenario(SCEN_LIST_INFO_TEST);
- ITraceControlComponent root = TraceControlTestFacility.getInstance().getControlView().getTraceControlRoot();
+ ITraceControlComponent root = fFacility.getControlView().getTraceControlRoot();
TargetNodeComponent node = new TargetNodeComponent(TARGET_NODE_NAME, root, fProxy);
root.addChild(node);
node.connect();
- TraceControlTestFacility.getInstance().waitForConnect(node);
- TraceControlTestFacility.getInstance().waitForJobs();
+ fFacility.waitForConnect(node);
+ fFacility.waitForJobs();
// ------------------------------------------------------------------------
// Verify Parameters of TargetNodeComponent
*/
@After
public void tearDown() {
- fFacility.waitForJobs();
fFacility.dispose();
}
*/
@After
public void tearDown() {
- fFacility.waitForJobs();
fFacility.dispose();
}
//-------------------------------------------------------------------------
fFacility.executeCommand(node, "delete");
-
assertEquals("Node not deleted.", 0, fFacility.getControlView().getTraceControlRoot().getChildren().length);
}
}
\ No newline at end of file
*/
@After
public void tearDown() {
- fFacility.waitForJobs();
fFacility.dispose();
}
//-------------------------------------------------------------------------
fFacility.executeCommand(node, "delete");
-
assertEquals(0,fFacility.getControlView().getTraceControlRoot().getChildren().length);
}
}
\ No newline at end of file