Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'build/org.eclipse.cdt.cmake.ui.tests/src/org/eclipse/cdt/cmake/ui/internal/tests/NewCMakeProjectTest.java')
-rw-r--r--build/org.eclipse.cdt.cmake.ui.tests/src/org/eclipse/cdt/cmake/ui/internal/tests/NewCMakeProjectTest.java97
1 files changed, 97 insertions, 0 deletions
diff --git a/build/org.eclipse.cdt.cmake.ui.tests/src/org/eclipse/cdt/cmake/ui/internal/tests/NewCMakeProjectTest.java b/build/org.eclipse.cdt.cmake.ui.tests/src/org/eclipse/cdt/cmake/ui/internal/tests/NewCMakeProjectTest.java
new file mode 100644
index 00000000000..0f425bf2736
--- /dev/null
+++ b/build/org.eclipse.cdt.cmake.ui.tests/src/org/eclipse/cdt/cmake/ui/internal/tests/NewCMakeProjectTest.java
@@ -0,0 +1,97 @@
+/*******************************************************************************
+ * Copyright (c) 2017 QNX Software Systems 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
+ *******************************************************************************/
+package org.eclipse.cdt.cmake.ui.internal.tests;
+
+import static org.eclipse.swtbot.eclipse.finder.matchers.WidgetMatcherFactory.withPartName;
+import static org.junit.Assert.assertTrue;
+
+import org.eclipse.cdt.cmake.core.CMakeNature;
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.index.IIndexManager;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
+import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTable;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTableItem;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+@SuppressWarnings("nls")
+public class NewCMakeProjectTest {
+
+ private static SWTWorkbenchBot bot;
+
+ @BeforeClass
+ public static void beforeClass() {
+ SWTBotPreferences.KEYBOARD_LAYOUT = "EN_US";
+ SWTBotPreferences.TIMEOUT = 10000;
+ bot = new SWTWorkbenchBot();
+ }
+
+ @Before
+ public void before() {
+ bot.resetWorkbench();
+
+ for (SWTBotView view : bot.views(withPartName("Welcome"))) {
+ view.close();
+ }
+ }
+
+ @Test(timeout = 60000)
+ public void createCMakeProject() throws Exception {
+ // open C++ perspective
+ if (!"C/C++".equals(bot.activePerspective().getLabel())) {
+ bot.perspectiveByLabel("C/C++").activate();
+ }
+
+ // Activate C/C++ wizard
+ bot.menu("File").menu("New").menu("C/C++ Project").click();
+ bot.shell("New C/C++ Project").activate();
+
+ // Double click on the template
+ SWTBotTable templateTable = bot.table();
+ bot.getDisplay().syncExec(() -> {
+ for (int i = 0; i < templateTable.rowCount(); ++i) {
+ SWTBotTableItem item = templateTable.getTableItem(i);
+ if ("CMake Project".equals(item.widget.getData(SWTBotPreferences.DEFAULT_KEY))) {
+ item.doubleClick();
+ break;
+ }
+ }
+ });
+
+ // Select the shell again since magic wizardry happened
+ bot.shell("New CMake Project").activate();
+
+ // Create the project
+ String projectName = "CMakeTestProj";
+ bot.textWithLabel("Project name:").setText(projectName);
+ bot.button("Finish").click();
+
+ // Make sure it shows up in Project Explorer
+ bot.viewByPartName("Project Explorer").show();
+ bot.tree().getTreeItem(projectName);
+
+ // Make sure the project indexer completes. At that point we're stable.
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+ ICProject cproject = CoreModel.getDefault().create(project);
+ IIndexManager indexManager = CCorePlugin.getIndexManager();
+ while (!indexManager.isProjectContentSynced(cproject)) {
+ Thread.sleep(1000);
+ }
+
+ // Make sure it has the right nature
+ assertTrue(project.hasNature(CMakeNature.ID));
+ }
+
+}

Back to the top