Skip to content

Commit 7e2946b

Browse files
SWTBot test case: JTAG Flash Process verification (#1300)
* ci: add first JTAG Flash test bump IDF version to 5.4 to solve board detection issue Temporary isolate test for Linux runner only
1 parent 6f62d42 commit 7e2946b

File tree

4 files changed

+195
-10
lines changed

4 files changed

+195
-10
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
repository: espressif/esp-idf
2727
path: dependencies/idf-tools
2828
submodules: 'true'
29-
ref: release/v5.1
29+
ref: release/v5.4
3030

3131
- name: Set up Python
3232
uses: actions/setup-python@v2
Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
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 JTAG Flash Process
33+
*
34+
* @author Andrii Filippov
35+
*
36+
*/
37+
38+
@SuppressWarnings("restriction")
39+
@RunWith(SWTBotJunit4ClassRunner.class)
40+
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
41+
public class IDFProjectJTAGFlashTest
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 givenNewProjectCreatedWhenSelectJTAGflashWhenBuiltThenCheckFlashedSuccessfully() 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("NewProjectJTAGFlashTest");
69+
Fixture.whenNewProjectIsSelected();
70+
Fixture.whenSelectJTAGflashInLaunchConfig();
71+
Fixture.whenSelectLaunchTargetBoard();
72+
Fixture.whenProjectIsBuiltUsingContextMenu();
73+
Fixture.whenFlashProject();
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 whenFlashProject() throws IOException
121+
{
122+
ProjectTestOperations.launchCommandUsingContextMenu(projectName, bot, "Run Configurations...");
123+
TestWidgetWaitUtility.waitForDialogToAppear(bot, "Run Configurations", 10000);
124+
bot.tree().getTreeItem("ESP-IDF Application").select();
125+
bot.tree().getTreeItem("ESP-IDF Application").expand();
126+
bot.tree().getTreeItem("ESP-IDF Application").getNode(projectName).select();
127+
bot.waitUntil(widgetIsEnabled(bot.button("Run")), 5000);
128+
bot.button("Run").click();
129+
}
130+
131+
private static void whenSelectJTAGflashInLaunchConfig() throws Exception
132+
{
133+
LaunchBarConfigSelector configSelector = new LaunchBarConfigSelector(bot);
134+
configSelector.clickEdit();
135+
TestWidgetWaitUtility.waitForDialogToAppear(bot, "Edit Configuration", 20000);
136+
bot.cTabItem("Main").show();
137+
bot.cTabItem("Main").setFocus();
138+
bot.comboBoxWithLabel("Flash over:").setSelection("JTAG");
139+
bot.button("OK").click();
140+
}
141+
142+
private static void whenSelectLaunchTargetBoard() throws Exception
143+
{
144+
LaunchBarTargetSelector targetSelector = new LaunchBarTargetSelector(bot);
145+
targetSelector.clickEdit();
146+
TestWidgetWaitUtility.waitForDialogToAppear(bot, "New ESP Target", 20000);
147+
SWTBotShell shell = bot.shell("New ESP Target");
148+
bot.comboBoxWithLabel("Board:").setSelection("ESP32-ETHERNET-KIT [usb://1-10]");
149+
TestWidgetWaitUtility.waitForOperationsInProgressToFinishSync(bot);
150+
shell.setFocus();
151+
bot.button("Finish").click();
152+
}
153+
154+
private static void thenVerifyJTAGflashDone() throws Exception
155+
{
156+
ProjectTestOperations.verifyTheConsoleOutput(bot, "** Flashing done for partition_table/partition-table.bin");
157+
}
158+
159+
private static void cleanTestEnv()
160+
{
161+
TestWidgetWaitUtility.waitForOperationsInProgressToFinishAsync(bot);
162+
ProjectTestOperations.closeAllProjects(bot);
163+
ProjectTestOperations.deleteAllProjects(bot);
164+
}
165+
}
166+
}

tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectFlashProcessTest.java

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@
66

77
import java.io.IOException;
88

9+
import org.apache.commons.lang3.SystemUtils;
910
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
1011
import static org.eclipse.swtbot.swt.finder.waits.Conditions.*;
12+
import static org.junit.Assert.assertTrue;
13+
1114
import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
1215
import org.eclipse.swtbot.swt.finder.widgets.SWTBotCheckBox;
1316
import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
@@ -60,14 +63,21 @@ public void afterEachTest()
6063
public void givenNewProjectCreatedBuiltWhenSelectSerialPortWhenFlashThenCheckFlashedSuccessfully()
6164
throws Exception
6265
{
63-
Fixture.givenNewEspressifIDFProjectIsSelected("EspressIf", "Espressif IDF Project");
64-
Fixture.givenProjectNameIs("NewProjectFlashTest");
65-
Fixture.whenNewProjectIsSelected();
66-
Fixture.whenTurnOffOpenSerialMonitorAfterFlashingInLaunchConfig();
67-
Fixture.whenProjectIsBuiltUsingContextMenu();
68-
Fixture.whenSelectLaunchTargetSerialPort();
69-
Fixture.whenFlashProject();
70-
Fixture.thenVerifyFlashDoneSuccessfully();
66+
if (SystemUtils.IS_OS_LINUX) //temporary solution until new ESP boards arrive for Windows
67+
{
68+
Fixture.givenNewEspressifIDFProjectIsSelected("EspressIf", "Espressif IDF Project");
69+
Fixture.givenProjectNameIs("NewProjectFlashTest");
70+
Fixture.whenNewProjectIsSelected();
71+
Fixture.whenTurnOffOpenSerialMonitorAfterFlashingInLaunchConfig();
72+
Fixture.whenProjectIsBuiltUsingContextMenu();
73+
Fixture.whenSelectLaunchTargetSerialPort();
74+
Fixture.whenFlashProject();
75+
Fixture.thenVerifyFlashDoneSuccessfully();
76+
}
77+
else
78+
{
79+
assertTrue(true);
80+
}
7181
}
7282

7383
private static class Fixture

tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/operations/ProjectTestOperations.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public class ProjectTestOperations
5252
{
5353

5454
private static final String DEFAULT_PROJECT_BUILD_WAIT_PROPERTY = "default.project.build.wait";
55-
55+
5656
private static final String DEFAULT_FLASH_WAIT_PROPERTY = "default.project.flash.wait";
5757

5858
private static final Logger logger = LoggerFactory.getLogger(ProjectTestOperations.class);
@@ -755,6 +755,15 @@ public static void deletePartitionTableRow(SWTWorkbenchBot bot) throws IOExcepti
755755
bot.button("OK").click();
756756
}
757757

758+
759+
public static void verifyTheConsoleOutput(SWTWorkbenchBot bot, String text) throws IOException
760+
{
761+
SWTBotView view = bot.viewByPartName("Console");
762+
view.setFocus();
763+
TestWidgetWaitUtility.waitUntilViewContains(bot, text, view,
764+
DefaultPropertyFetcher.getLongPropertyValue(DEFAULT_FLASH_WAIT_PROPERTY, 120000));
765+
}
766+
758767
public static void joinJobByName(String jobName)
759768
{
760769
Job[] jobs = Job.getJobManager().find(null);

0 commit comments

Comments
 (0)