use of com.intellij.execution.configurations.RunConfiguration in project android by JetBrains.
the class TestConfigurationTesting method createConfigurationFromPsiElement.
@Nullable
private static RunConfiguration createConfigurationFromPsiElement(@NotNull Project project, @NotNull PsiElement psiElement) {
ConfigurationContext context = createContext(project, psiElement);
RunnerAndConfigurationSettings settings = context.getConfiguration();
if (settings == null) {
return null;
}
RunConfiguration configuration = settings.getConfiguration();
if (configuration instanceof AndroidTestRunConfiguration || configuration instanceof AndroidJUnitConfiguration) {
return configuration;
}
return null;
}
use of com.intellij.execution.configurations.RunConfiguration in project intellij-plugins by JetBrains.
the class FlexModuleBuilder method createRunConfiguration.
public static void createRunConfiguration(final Module module, final FlexBuildConfiguration bc) {
final RunManager runManager = RunManagerEx.getInstance(module.getProject());
final List<RunConfiguration> existingConfigurations = runManager.getConfigurationsList(FlashRunConfigurationType.getInstance());
for (RunConfiguration configuration : existingConfigurations) {
final FlashRunnerParameters parameters = ((FlashRunConfiguration) configuration).getRunnerParameters();
if (module.getName().equals(parameters.getModuleName()) && bc.getName().equals(parameters.getBCName())) {
//already exists
return;
}
}
final RunnerAndConfigurationSettings settings = runManager.createConfiguration("", FlashRunConfigurationType.getFactory());
final FlashRunConfiguration runConfiguration = (FlashRunConfiguration) settings.getConfiguration();
final FlashRunnerParameters params = runConfiguration.getRunnerParameters();
params.setModuleName(module.getName());
params.setBCName(bc.getName());
if (bc.getNature().isMobilePlatform()) {
if (bc.getAndroidPackagingOptions().isEnabled()) {
params.setAppDescriptorForEmulator(FlashRunnerParameters.AppDescriptorForEmulator.Android);
} else if (bc.getIosPackagingOptions().isEnabled()) {
params.setAppDescriptorForEmulator(FlashRunnerParameters.AppDescriptorForEmulator.IOS);
}
}
settings.setName(params.suggestUniqueName(existingConfigurations));
settings.setTemporary(false);
runManager.addConfiguration(settings, false);
runManager.setSelectedConfiguration(settings);
}
use of com.intellij.execution.configurations.RunConfiguration in project android by JetBrains.
the class PostSyncProjectSetupTest method testJUnitRunConfigurationSetup.
public void testJUnitRunConfigurationSetup() {
when(myIdeInfo.isAndroidStudio()).thenReturn(true);
PostSyncProjectSetup.Request request = new PostSyncProjectSetup.Request();
mySetup.setUpProject(request, myProgressIndicator);
ConfigurationFactory configurationFactory = AndroidJUnitConfigurationType.getInstance().getConfigurationFactories()[0];
AndroidJUnitConfiguration jUnitConfiguration = new AndroidJUnitConfiguration("", getProject(), configurationFactory);
myRunManager.addConfiguration(myRunManager.createConfiguration(jUnitConfiguration, configurationFactory), true);
List<RunConfiguration> junitRunConfigurations = myRunManager.getConfigurationsList(AndroidJUnitConfigurationType.getInstance());
for (RunConfiguration runConfiguration : junitRunConfigurations) {
assertSize(1, myRunManager.getBeforeRunTasks(runConfiguration));
assertEquals(MakeBeforeRunTaskProvider.ID, myRunManager.getBeforeRunTasks(runConfiguration).get(0).getProviderId());
}
RunConfiguration runConfiguration = junitRunConfigurations.get(0);
List<BeforeRunTask> tasks = new LinkedList<>(myRunManager.getBeforeRunTasks(runConfiguration));
BeforeRunTask newTask = new MakeBeforeRunTaskProvider(getProject()).createTask(runConfiguration);
newTask.setEnabled(true);
tasks.add(newTask);
myRunManager.setBeforeRunTasks(runConfiguration, tasks, false);
mySetup.setUpProject(request, myProgressIndicator);
assertSize(2, myRunManager.getBeforeRunTasks(runConfiguration));
}
use of com.intellij.execution.configurations.RunConfiguration in project intellij-plugins by JetBrains.
the class JstdRunConfigurationProducer method setupConfigurationFromContext.
@Override
protected boolean setupConfigurationFromContext(JstdRunConfiguration configuration, ConfigurationContext context, Ref<PsiElement> sourceElement) {
Project project = configuration.getProject();
if (!JstdSettingsUtil.areJstdConfigFilesInProjectCached(project)) {
return false;
}
RunConfiguration original = context.getOriginalConfiguration(null);
if (original != null && !ConfigurationTypeUtil.equals(original.getType(), JstdConfigurationType.getInstance())) {
return false;
}
long startTimeNano = System.nanoTime();
@SuppressWarnings({ "unchecked" }) JstdRunSettings settings = buildRunSettingsContext(context.getLocation());
if (settings == null) {
logDoneCreateConfigurationByElement(startTimeNano, "1");
return false;
}
if (settings.getConfigFile().isEmpty()) {
JstdRunSettings clonedSettings = configuration.getRunSettings();
JstdRunSettings.Builder builder = new JstdRunSettings.Builder(settings);
builder.setConfigFile(clonedSettings.getConfigFile());
settings = builder.build();
}
configuration.setRunSettings(settings);
String configurationName = configuration.resetGeneratedName();
configuration.setName(configurationName);
logDoneCreateConfigurationByElement(startTimeNano, "3");
return true;
}
use of com.intellij.execution.configurations.RunConfiguration in project intellij-plugins by JetBrains.
the class FlexUnitConfigurationTest method doTest.
private void doTest(String filename) throws Exception {
configureByFile(BASE_PATH + filename);
final Map<Integer, String> markers = JSTestUtils.extractPositionMarkers(getProject(), getEditor().getDocument());
assertFalse("No caret markers found", markers.isEmpty());
assertFalse("No 'expected' value", markers.containsValue(null));
final DataContext dataContext = DataManager.getInstance().getDataContext(getEditor().getComponent());
int i = 1;
for (Map.Entry<Integer, String> marker : markers.entrySet()) {
String place = filename + ": marker " + i++ + ": ";
getEditor().getCaretModel().moveToOffset(marker.getKey());
final ConfigurationFromContext configurationFromContext = new FlexUnitRuntimeConfigurationProducer().createConfigurationFromContext(ConfigurationContext.getFromContext(dataContext));
final RunConfiguration configuration = configurationFromContext == null ? null : configurationFromContext.getConfiguration();
if ("null".equals(marker.getValue())) {
assertNull(place + "Null configuration expected", configuration);
} else {
assertNotNull(place + "Not null configuration expected", configuration);
assertTrue(place + "Invalid configuration", configuration instanceof FlexUnitRunConfiguration);
final String[] expected;
if ("null".equals(marker.getValue())) {
expected = null;
} else {
expected = marker.getValue().split(" ");
assertEquals(place + "Expected should be in the form: \"Class com.test.Foo\" or \"Method com.test.Foo.testBar()\" or \"Package com.test\"", 2, expected.length);
}
final FlexUnitRunnerParameters params = ((FlexUnitRunConfiguration) configuration).getRunnerParameters();
assertEquals(place + "Invalid scope", expected[0], params.getScope().name());
final String definition;
switch(params.getScope()) {
case Class:
definition = params.getClassName();
break;
case Method:
definition = params.getClassName() + "." + params.getMethodName() + "()";
break;
case Package:
definition = params.getPackageName();
break;
default:
fail(place + "Unknown scope: " + params.getScope());
definition = null;
}
assertEquals(place + "Invalid definition", expected[1], definition);
}
}
}
Aggregations