Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 8f43cfa5acc636e91c854714367eee56ca9b17c2 (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
90
91
92
93
94
95
96
97
98
99
100
101
102
/*******************************************************************************
 * Copyright (c) 2007, 2011 Intel Corporation and others.
 *
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License 2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 * Intel Corporation - Initial API and implementation
 *******************************************************************************/
package org.eclipse.cdt.projectmodel.tests;

import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;

import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager;
import org.eclipse.cdt.core.testplugin.ResourceHelper;
import org.eclipse.cdt.managedbuilder.testplugin.ManagedBuildTestHelper;
import org.eclipse.core.resources.IProject;

import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;

public class BackwardCompatiblityTests extends TestCase {
	private static final String TEST_3X_STD_MAKE_PROJECTS = "test3xStdMakeProjects";

	private List<IProject> projList = new LinkedList<IProject>();

	public static Test suite() {
		return new TestSuite(BackwardCompatiblityTests.class);
	}

	public void test3xStdMakeProject() {
		String PROJ_NAME = "std_cpp_1";

		//		String[] BIN_PARSERS = new String[]{
		//				"org.eclipse.cdt.core.ELF",
		//				"org.eclipse.cdt.core.PE",
		//				"org.eclipse.cdt.core.GNU_ELF",
		//				"org.eclipse.cdt.core.MachO"
		//		};
		//
		//		String[] ERR_PARSERS = new String[]{
		//				"org.eclipse.cdt.core.CWDLocator",
		//				"org.eclipse.cdt.core.GASErrorParser",
		//				"org.eclipse.cdt.core.VCErrorParser",
		//				"org.eclipse.cdt.core.GmakeErrorParser",
		//		};

		IProject project = loadStdProject(PROJ_NAME);
		projList.add(project);

		ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager();
		assertFalse(mngr.isNewStyleProject(project));
		ICProjectDescription des = mngr.getProjectDescription(project, false);
		checkDescription(des);

		des = mngr.getProjectDescription(project, true);
		checkDescription(des);

	}

	private void checkDescription(ICProjectDescription des) {
		ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager();

		assertFalse(mngr.isNewStyleProject(des));
		assertFalse(des.isCdtProjectCreating());
		assertEquals(1, des.getConfigurations().length);

	}

	private IProject loadStdProject(String name) {
		return ManagedBuildTestHelper.loadProject(name, TEST_3X_STD_MAKE_PROJECTS);
	}

	@Override
	protected void setUp() throws Exception {
		super.setUp();
	}

	@Override
	protected void tearDown() throws Exception {
		ResourceHelper.cleanUp(getName());
		for (Iterator<IProject> iter = projList.iterator(); iter.hasNext();) {
			IProject proj = iter.next();
			try {
				proj.delete(true, null);
			} catch (Exception e) {
			}
			iter.remove();
		}
		super.tearDown();
	}

}

Back to the top