-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Tests] Add test for the launch configuration shortcut
prevents #130 Signed-off-by: Jonas Hungershausen <jonas.hungershausen@vogella.com>
- Loading branch information
Jonas Hungershausen
committed
Aug 20, 2019
1 parent
f503e9e
commit 78cfdf1
Showing
1 changed file
with
64 additions
and
0 deletions.
There are no files selected for viewing
64 changes: 64 additions & 0 deletions
64
org.eclipse.dartboard.test/src/org/eclipse/dartboard/test/launch/LaunchShortcutTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package org.eclipse.dartboard.test.launch; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertNotNull; | ||
|
||
import org.eclipse.dartboard.Constants; | ||
import org.eclipse.dartboard.test.util.ProjectUtil; | ||
import org.eclipse.debug.core.DebugPlugin; | ||
import org.eclipse.debug.core.ILaunchConfiguration; | ||
import org.eclipse.debug.core.ILaunchManager; | ||
import org.eclipse.reddeer.common.matcher.RegexMatcher; | ||
import org.eclipse.reddeer.common.wait.WaitUntil; | ||
import org.eclipse.reddeer.core.matcher.WithMnemonicTextMatcher; | ||
import org.eclipse.reddeer.eclipse.ui.navigator.resources.ProjectExplorer; | ||
import org.eclipse.reddeer.junit.runner.RedDeerSuite; | ||
import org.eclipse.reddeer.swt.condition.ShellIsActive; | ||
import org.eclipse.reddeer.swt.impl.button.PushButton; | ||
import org.eclipse.reddeer.swt.impl.combo.LabeledCombo; | ||
import org.eclipse.reddeer.swt.impl.menu.ContextMenuItem; | ||
import org.eclipse.reddeer.swt.impl.text.LabeledText; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import net.bytebuddy.utility.RandomString; | ||
|
||
@RunWith(RedDeerSuite.class) | ||
public class LaunchShortcutTest { | ||
|
||
@SuppressWarnings("unchecked") | ||
@Test | ||
public void launchShortcut__DartProjectNoLaunchConfig__NewLaunchConfigIsCreated() throws Exception { | ||
String projectName = RandomString.make(8); | ||
String mainClass = RandomString.make(4) + ".dart"; | ||
ProjectUtil.createDartProject(projectName); | ||
|
||
ProjectExplorer projectExplorer = new ProjectExplorer(); | ||
projectExplorer.open(); | ||
projectExplorer.getProject(projectName).select(); | ||
|
||
new ContextMenuItem(new WithMnemonicTextMatcher("Run As"), new RegexMatcher("\\d Run as Dart Program")) | ||
.select(); | ||
|
||
new WaitUntil(new ShellIsActive("Edit Configuration")); | ||
new LabeledCombo("Project:").setSelection(projectName); | ||
new LabeledText("Main class:").setText(mainClass); | ||
new PushButton("Run").click(); | ||
ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager(); | ||
|
||
// Find last launch configuration for selected project. | ||
ILaunchConfiguration launchConfiguration = null; | ||
for (ILaunchConfiguration conf : manager.getLaunchConfigurations()) { | ||
if (conf.getAttribute(Constants.LAUNCH_SELECTED_PROJECT, "").equalsIgnoreCase(projectName)) { //$NON-NLS-1$ | ||
launchConfiguration = conf; | ||
} | ||
} | ||
|
||
assertNotNull(launchConfiguration); | ||
assertEquals(launchConfiguration.getAttribute("main_class", ""), mainClass); | ||
|
||
// Cleanup | ||
launchConfiguration.delete(); | ||
} | ||
|
||
} |