Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SWTBot test case: DebugLaunchConfigTest #795

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import static org.junit.Assert.assertTrue;

import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.Optional;

Expand All @@ -21,6 +23,7 @@
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotText;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarButton;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
import org.junit.After;
Expand Down Expand Up @@ -186,6 +189,20 @@ public void givenNewProjectCreatedDfuBuiltThenHasDfuBin() throws Exception
Fixture.thenProjectHasTheFile("dfu.bin", "/build");
Fixture.turnOffDfu();
}

@Test
public void whenProjectIsSelectedInProjectExplorerThenNewDebugConfigurationHasPrefilledAllFields() throws Exception
{
Fixture.givenNewEspressifIDFProjectIsSelected("EspressIf", "Espressif IDF Project");
Fixture.givenProjectNameIs("NewProjectTest");
Fixture.whenNewProjectIsSelected();
Fixture.givenESP32LaunchTargetIsSelected();
Fixture.selectNewDebugLaunchConfig();
Fixture.compareProjectName();
Fixture.compareActualExePath();
Fixture.compareSVDPath();
Fixture.finishDebugLaunchConfigCreation();
}

private static class Fixture
{
Expand Down Expand Up @@ -277,6 +294,44 @@ private static void turnOnDfu()
bot.comboBox().setSelection("DFU");
bot.button("OK").click();
}

private static void givenESP32LaunchTargetIsSelected()
{
launchBarTargetSelector.select("esp32");
}

private static void selectNewDebugLaunchConfig()
{
launchBarConfigSelector.select("New Launch Configuration...");
bot.table(0).select("Debug");
bot.table(1).select("ESP-IDF GDB OpenOCD Debugging");
bot.button("Next >").click();
}

private static void compareProjectName()
{
SWTBotText textWidget = bot.textWithLabel("Project:");
assertTrue(textWidget.getText().equals(projectName));
}

private static void compareActualExePath()
{
bot.cTabItem("Debugger").activate();
SWTBotText actualExeTxtWidget = bot.textWithLabel("Actual Executable:");
assertTrue(actualExeTxtWidget.getText().contains("xtensa-esp32-elf-gdb.exe"));
}

private static void compareSVDPath()
{
bot.cTabItem("SVD Path").activate();
SWTBotText filePathTxtWidget = bot.textWithLabel("File path:");
assertTrue(filePathTxtWidget.getText().contains("esp32.svd"));
}

private static void finishDebugLaunchConfigCreation()
{
bot.button("Finish").click();
}

private static void whenProjectIsBuiltUsingContextMenu() throws IOException
{
Expand Down