Search in sources :

Example 11 with ILaunchConfigurationWorkingCopy

use of org.eclipse.debug.core.ILaunchConfigurationWorkingCopy in project linuxtools by eclipse.

the class TestSetup method testSetupTab.

@Test
public void testSetupTab() throws CoreException {
    OprofileTestingSetupTab tab = new OprofileTestingSetupTab();
    tab.createControl(new Shell());
    assertNotNull(tab.getImage());
    assertNotNull(tab.getName());
    ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy();
    // default config
    tab.setDefaults(wc);
    tab.initializeFrom(config);
    Button libraryCheck = tab.getLibraryCheck();
    libraryCheck.setSelection(true);
    libraryCheck.notifyListeners(SWT.Selection, null);
    performApply(tab, wc);
    assertEquals(OprofileDaemonOptions.SEPARATE_LIBRARY, config.getAttribute(OprofileLaunchPlugin.ATTR_SEPARATE_SAMPLES, -1));
    libraryCheck.setSelection(false);
    libraryCheck.notifyListeners(SWT.Selection, null);
    performApply(tab, wc);
    assertEquals(OprofileDaemonOptions.SEPARATE_NONE, config.getAttribute(OprofileLaunchPlugin.ATTR_SEPARATE_SAMPLES, -1));
    Button kernelCheck = tab.getKernelCheck();
    kernelCheck.setSelection(true);
    kernelCheck.notifyListeners(SWT.Selection, null);
    performApply(tab, wc);
    assertEquals(OprofileDaemonOptions.SEPARATE_KERNEL, config.getAttribute(OprofileLaunchPlugin.ATTR_SEPARATE_SAMPLES, -1));
    kernelCheck.setSelection(false);
    kernelCheck.notifyListeners(SWT.Selection, null);
    performApply(tab, wc);
    assertEquals(OprofileDaemonOptions.SEPARATE_NONE, config.getAttribute(OprofileLaunchPlugin.ATTR_SEPARATE_SAMPLES, -1));
    libraryCheck.setSelection(true);
    libraryCheck.notifyListeners(SWT.Selection, null);
    kernelCheck.setSelection(true);
    kernelCheck.notifyListeners(SWT.Selection, null);
    performApply(tab, wc);
    tab.initializeFrom(config);
    assertTrue(libraryCheck.getSelection());
    assertTrue(kernelCheck.getSelection());
    Text kernelLocationText = tab.getTextKernelImage();
    // $NON-NLS-1$
    kernelLocationText.setText("doesntexist");
    kernelLocationText.notifyListeners(SWT.Selection, null);
    performApply(tab, wc);
    assertFalse(tab.isValid(config));
    // $NON-NLS-1$
    kernelLocationText.setText("");
    kernelLocationText.notifyListeners(SWT.Selection, null);
    performApply(tab, wc);
    assertTrue(tab.isValid(config));
}
Also used : Shell(org.eclipse.swt.widgets.Shell) Button(org.eclipse.swt.widgets.Button) Text(org.eclipse.swt.widgets.Text) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) Test(org.junit.Test) AbstractTest(org.eclipse.linuxtools.profiling.tests.AbstractTest)

Example 12 with ILaunchConfigurationWorkingCopy

use of org.eclipse.debug.core.ILaunchConfigurationWorkingCopy in project linuxtools by eclipse.

the class TestSetup method testEventConfigTab.

@Test
public void testEventConfigTab() throws CoreException {
    OprofileTestingEventConfigTab tab = new OprofileTestingEventConfigTab();
    tab.createControl(new Shell());
    assertNotNull(tab.getImage());
    assertNotNull(tab.getName());
    tab.setDefaults(config.getWorkingCopy());
    tab.initializeFrom(config);
    assertTrue(tab.isValid(config));
    assertTrue(tab.getDefaultCheck().getSelection());
    tab.getDefaultCheck().notifyListeners(SWT.Selection, null);
    tab.getDefaultCheck().setSelection(false);
    tab.getDefaultCheck().notifyListeners(SWT.Selection, null);
    ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy();
    wc.setAttribute(OprofileLaunchPlugin.ATTR_USE_DEFAULT_EVENT, false);
    performApply(tab, wc);
    assertFalse(tab.isValid(config));
}
Also used : OprofileTestingEventConfigTab(org.eclipse.linuxtools.oprofile.launch.tests.utils.OprofileTestingEventConfigTab) Shell(org.eclipse.swt.widgets.Shell) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) Test(org.junit.Test) AbstractTest(org.eclipse.linuxtools.profiling.tests.AbstractTest)

Example 13 with ILaunchConfigurationWorkingCopy

use of org.eclipse.debug.core.ILaunchConfigurationWorkingCopy in project linuxtools by eclipse.

the class ProfileLaunchShortcut method createConfiguration.

/**
 * Create a launch configuration based on a binary, and optionally
 * save it to the underlying resource.
 *
 * @param bin a representation of a binary
 * @param save true if the configuration should be saved to the
 * underlying resource, and false if it should not be saved.
 * @return a launch configuration generated for the binary.
 * @since 1.2
 */
protected ILaunchConfiguration createConfiguration(IBinary bin, boolean save) {
    ILaunchConfiguration config = null;
    try {
        String projectName = bin.getResource().getProjectRelativePath().toString();
        ILaunchConfigurationType configType = getLaunchConfigType();
        ILaunchConfigurationWorkingCopy wc = configType.newInstance(null, getLaunchManager().generateLaunchConfigurationName(bin.getElementName()));
        wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, projectName);
        wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, bin.getCProject().getElementName());
        wc.setMappedResources(new IResource[] { bin.getResource(), bin.getResource().getProject() });
        wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String) null);
        setDefaultProfileAttributes(wc);
        if (save) {
            config = wc.doSave();
        } else {
            config = wc;
        }
    } catch (CoreException e) {
        e.printStackTrace();
    }
    return config;
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) CoreException(org.eclipse.core.runtime.CoreException) ILaunchConfigurationType(org.eclipse.debug.core.ILaunchConfigurationType) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)

Example 14 with ILaunchConfigurationWorkingCopy

use of org.eclipse.debug.core.ILaunchConfigurationWorkingCopy in project linuxtools by eclipse.

the class LaunchTest method testDelegate.

@Test
public void testDelegate() throws CoreException {
    ILaunchConfiguration config = createConfiguration(proj.getProject());
    ProviderLaunchConfigurationDelegate delegate = new ProviderLaunchConfigurationDelegate();
    ILaunch launch = new Launch(config, ILaunchManager.PROFILE_MODE, null);
    ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy();
    setProfileAttributes(wc);
    delegate.launch(wc, ILaunchManager.PROFILE_MODE, launch, null);
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) ILaunch(org.eclipse.debug.core.ILaunch) ProviderLaunchConfigurationDelegate(org.eclipse.linuxtools.internal.profiling.launch.provider.launch.ProviderLaunchConfigurationDelegate) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) Launch(org.eclipse.debug.core.Launch) ILaunch(org.eclipse.debug.core.ILaunch) Test(org.junit.Test) AbstractTest(org.eclipse.linuxtools.profiling.tests.AbstractTest)

Example 15 with ILaunchConfigurationWorkingCopy

use of org.eclipse.debug.core.ILaunchConfigurationWorkingCopy in project linuxtools by eclipse.

the class LaunchConfigTabTest method testTrackLockorders.

@Test
public void testTrackLockorders() throws CoreException, URISyntaxException, IOException {
    ILaunchConfigurationWorkingCopy wc = initConfig();
    dynamicTab.getLockordersButton().setSelection(false);
    tab.performApply(wc);
    wc.doSave();
    // $NON-NLS-1$
    ILaunch launch = saveAndLaunch(wc, "testHelgrindGeneric");
    IProcess[] p = launch.getProcesses();
    assertTrue("process array should not be empty", p.length > 0);
    String cmd = p[0].getAttribute(IProcess.ATTR_CMDLINE);
    assertEquals(0, p[0].getExitValue());
    // $NON-NLS-1$
    assertTrue(cmd.contains("--track-lockorders=no"));
}
Also used : ILaunch(org.eclipse.debug.core.ILaunch) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) IProcess(org.eclipse.debug.core.model.IProcess) Test(org.junit.Test)

Aggregations

ILaunchConfigurationWorkingCopy (org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)119 Test (org.junit.Test)75 ILaunch (org.eclipse.debug.core.ILaunch)52 IProcess (org.eclipse.debug.core.model.IProcess)49 ILaunchConfiguration (org.eclipse.debug.core.ILaunchConfiguration)29 ILaunchConfigurationType (org.eclipse.debug.core.ILaunchConfigurationType)18 CoreException (org.eclipse.core.runtime.CoreException)16 IPath (org.eclipse.core.runtime.IPath)12 ILaunchManager (org.eclipse.debug.core.ILaunchManager)10 AbstractTest (org.eclipse.linuxtools.profiling.tests.AbstractTest)8 IProject (org.eclipse.core.resources.IProject)7 Shell (org.eclipse.swt.widgets.Shell)7 ArrayList (java.util.ArrayList)6 Path (org.eclipse.core.runtime.Path)6 ILaunchConfigurationTab (org.eclipse.debug.ui.ILaunchConfigurationTab)5 Version (org.osgi.framework.Version)5 IResource (org.eclipse.core.resources.IResource)4 Launch (org.eclipse.debug.core.Launch)3 MassifViewPart (org.eclipse.linuxtools.internal.valgrind.massif.MassifViewPart)3 Button (org.eclipse.swt.widgets.Button)3