Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: b21f841fad0d724235f0d7a122b4de345468efc9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*******************************************************************************
 * Copyright (c) 2009 Red Hat, Inc.
 * 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:
 *    Elliott Baron <ebaron@redhat.com> - initial API and implementation
 *******************************************************************************/
package org.eclipse.linuxtools.valgrind.memcheck.tests;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.linuxtools.valgrind.launch.ValgrindLaunchPlugin;
import org.eclipse.linuxtools.valgrind.launch.ValgrindOptionsTab;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.osgi.framework.Version;

public class MinVersionTest extends AbstractMemcheckTest {
	private static final Version VER_3_2_1 = new Version(3, 2, 1);
	private Version verSave;
	
	@Override
	protected void setUp() throws Exception {
		super.setUp();
		proj = createProjectAndBuild("basicTest"); //$NON-NLS-1$
		
		saveVersion();
	}

	private void saveVersion() throws CoreException {
		verSave = ValgrindLaunchPlugin.getDefault().getValgrindVersion();
		ValgrindLaunchPlugin.getDefault().setValgrindVersion(VER_3_2_1);
	}
	
	@Override
	protected void tearDown() throws Exception {
		restoreVersion();
		
		deleteProject(proj);
		super.tearDown();
	}

	private void restoreVersion() {
		ValgrindLaunchPlugin.getDefault().setValgrindVersion(verSave);
	}
		
	public void testLaunchBadVersion() throws Exception {
		// Put this back so we can make a valid config
		restoreVersion();
		ILaunchConfiguration config = createConfiguration(proj.getProject());
		// For some reason we downgraded
		saveVersion();
		
		CoreException ce = null;		
		try {
			doLaunch(config, "testDefaults"); //$NON-NLS-1$
		} catch (CoreException e) {
			ce = e;
		}
		
		assertNotNull(ce);
	}
	
	public void testTabsBadVersion() throws Exception {
		Shell testShell = new Shell(Display.getDefault());
		testShell.setLayout(new GridLayout());
		ValgrindOptionsTab tab = new ValgrindOptionsTab();
		
		ILaunchConfiguration config = getLaunchConfigType().newInstance(null, getLaunchManager()
				.generateUniqueLaunchConfigurationNameFrom(
						proj.getProject().getName()));
		ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy();
		tab.setDefaults(wc);
		tab.createControl(testShell);
		tab.initializeFrom(config);
		tab.performApply(wc);
		
		assertFalse(tab.isValid(config));
		assertNotNull(tab.getErrorMessage());
		
		testShell.dispose();
	}

}

Back to the top