Skip to content

Commit 4b4df68

Browse files
ci: add Debug test
1 parent 7e2946b commit 4b4df68

File tree

1 file changed

+161
-0
lines changed

1 file changed

+161
-0
lines changed
Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
/*******************************************************************************
2+
* Copyright 2025 Espressif Systems (Shanghai) PTE LTD.
3+
* All rights reserved. Use is subject to license terms.
4+
*******************************************************************************/
5+
6+
package com.espressif.idf.ui.test.executable.cases.project;
7+
8+
import java.io.IOException;
9+
10+
import org.apache.commons.lang3.SystemUtils;
11+
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
12+
import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
13+
import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
14+
import org.junit.After;
15+
import org.junit.BeforeClass;
16+
import org.junit.FixMethodOrder;
17+
import org.junit.Test;
18+
import org.junit.runner.RunWith;
19+
import org.junit.runners.MethodSorters;
20+
21+
import com.espressif.idf.ui.test.common.WorkBenchSWTBot;
22+
import static org.eclipse.swtbot.swt.finder.waits.Conditions.*;
23+
import static org.junit.Assert.assertTrue;
24+
25+
import com.espressif.idf.ui.test.common.utility.TestWidgetWaitUtility;
26+
import com.espressif.idf.ui.test.operations.EnvSetupOperations;
27+
import com.espressif.idf.ui.test.operations.ProjectTestOperations;
28+
import com.espressif.idf.ui.test.operations.selectors.LaunchBarConfigSelector;
29+
import com.espressif.idf.ui.test.operations.selectors.LaunchBarTargetSelector;
30+
31+
/**
32+
* Test class to test Debug Process
33+
*
34+
* @author Andrii Filippov
35+
*
36+
*/
37+
38+
@SuppressWarnings("restriction")
39+
@RunWith(SWTBotJunit4ClassRunner.class)
40+
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
41+
public class IDFProjectDebugProcessTest
42+
{
43+
@BeforeClass
44+
public static void beforeTestClass() throws Exception
45+
{
46+
Fixture.loadEnv();
47+
}
48+
49+
@After
50+
public void afterEachTest()
51+
{
52+
try
53+
{
54+
Fixture.cleanTestEnv();
55+
}
56+
catch (Exception e)
57+
{
58+
System.err.println("Error during cleanup: " + e.getMessage());
59+
}
60+
}
61+
62+
@Test
63+
public void givenNewProjectCreatedWhenSelectDebugWhenBuiltThenCheckDebugSuccessfully() throws Exception
64+
{
65+
if (SystemUtils.IS_OS_LINUX) //temporary solution until new ESP boards arrive for Windows
66+
{
67+
Fixture.givenNewEspressifIDFProjectIsSelected("EspressIf", "Espressif IDF Project");
68+
Fixture.givenProjectNameIs("NewProjecDebugTest");
69+
Fixture.whenNewProjectIsSelected();
70+
Fixture.whenSelectDebugConfig();
71+
Fixture.whenSelectLaunchTargetBoard();
72+
Fixture.whenProjectIsBuiltUsingContextMenu();
73+
Fixture.whenDebugProject();
74+
Fixture.thenVerifyJTAGflashDone();
75+
}
76+
else
77+
{
78+
assertTrue(true);
79+
}
80+
}
81+
82+
private static class Fixture
83+
{
84+
private static SWTWorkbenchBot bot;
85+
private static String category;
86+
private static String subCategory;
87+
private static String projectName;
88+
89+
private static void loadEnv() throws Exception
90+
{
91+
bot = WorkBenchSWTBot.getBot();
92+
EnvSetupOperations.setupEspressifEnv(bot);
93+
bot.sleep(1000);
94+
ProjectTestOperations.deleteAllProjects(bot);
95+
}
96+
97+
private static void givenNewEspressifIDFProjectIsSelected(String category, String subCategory)
98+
{
99+
Fixture.category = category;
100+
Fixture.subCategory = subCategory;
101+
}
102+
103+
private static void givenProjectNameIs(String projectName)
104+
{
105+
Fixture.projectName = projectName;
106+
}
107+
108+
private static void whenNewProjectIsSelected() throws Exception
109+
{
110+
ProjectTestOperations.setupProject(projectName, category, subCategory, bot);
111+
}
112+
113+
private static void whenProjectIsBuiltUsingContextMenu() throws IOException
114+
{
115+
ProjectTestOperations.buildProjectUsingContextMenu(projectName, bot);
116+
ProjectTestOperations.waitForProjectBuild(bot);
117+
TestWidgetWaitUtility.waitForOperationsInProgressToFinishAsync(bot);
118+
}
119+
120+
private static void whenDebugProject() throws IOException
121+
{
122+
ProjectTestOperations.launchCommandUsingContextMenu(projectName, bot, "Debug Configurations...");
123+
TestWidgetWaitUtility.waitForDialogToAppear(bot, "Debug Configurations", 10000);
124+
bot.tree().getTreeItem("ESP-IDF GDB OpenOCD Debugging").select();
125+
bot.tree().getTreeItem("ESP-IDF GDB OpenOCD Debugging").expand();
126+
bot.tree().getTreeItem("ESP-IDF GDB OpenOCD Debugging").getNode(projectName + " Debug").select();
127+
bot.waitUntil(widgetIsEnabled(bot.button("Debug")), 5000);
128+
bot.button("Debug").click();
129+
}
130+
131+
private static void whenSelectDebugConfig() throws Exception
132+
{
133+
LaunchBarConfigSelector configSelector = new LaunchBarConfigSelector(bot);
134+
configSelector.select(projectName + " Debug");
135+
}
136+
137+
private static void whenSelectLaunchTargetBoard() throws Exception
138+
{
139+
LaunchBarTargetSelector targetSelector = new LaunchBarTargetSelector(bot);
140+
targetSelector.clickEdit();
141+
TestWidgetWaitUtility.waitForDialogToAppear(bot, "New ESP Target", 20000);
142+
SWTBotShell shell = bot.shell("New ESP Target");
143+
bot.comboBoxWithLabel("Board:").setSelection("ESP32-ETHERNET-KIT [usb://1-10]");
144+
TestWidgetWaitUtility.waitForOperationsInProgressToFinishSync(bot);
145+
shell.setFocus();
146+
bot.button("Finish").click();
147+
}
148+
149+
private static void thenVerifyJTAGflashDone() throws Exception
150+
{
151+
ProjectTestOperations.verifyTheConsoleOutput(bot, "** Flashing done for partition_table/partition-table.bin");
152+
}
153+
154+
private static void cleanTestEnv()
155+
{
156+
TestWidgetWaitUtility.waitForOperationsInProgressToFinishAsync(bot);
157+
ProjectTestOperations.closeAllProjects(bot);
158+
ProjectTestOperations.deleteAllProjects(bot);
159+
}
160+
}
161+
}

0 commit comments

Comments
 (0)