-
Notifications
You must be signed in to change notification settings - Fork 131
SWTBot test case: JTAG Flash Process verification #1300
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
166 changes: 166 additions & 0 deletions
166
....test/src/com/espressif/idf/ui/test/executable/cases/project/IDFProjectJTAGFlashTest.java
This file contains hidden or 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,166 @@ | ||
/******************************************************************************* | ||
* Copyright 2025 Espressif Systems (Shanghai) PTE LTD. | ||
* All rights reserved. Use is subject to license terms. | ||
*******************************************************************************/ | ||
|
||
package com.espressif.idf.ui.test.executable.cases.project; | ||
|
||
import java.io.IOException; | ||
|
||
import org.apache.commons.lang3.SystemUtils; | ||
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; | ||
import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; | ||
import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell; | ||
import org.junit.After; | ||
import org.junit.BeforeClass; | ||
import org.junit.FixMethodOrder; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.junit.runners.MethodSorters; | ||
|
||
import com.espressif.idf.ui.test.common.WorkBenchSWTBot; | ||
import static org.eclipse.swtbot.swt.finder.waits.Conditions.*; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
import com.espressif.idf.ui.test.common.utility.TestWidgetWaitUtility; | ||
import com.espressif.idf.ui.test.operations.EnvSetupOperations; | ||
import com.espressif.idf.ui.test.operations.ProjectTestOperations; | ||
import com.espressif.idf.ui.test.operations.selectors.LaunchBarConfigSelector; | ||
import com.espressif.idf.ui.test.operations.selectors.LaunchBarTargetSelector; | ||
|
||
/** | ||
* Test class to test JTAG Flash Process | ||
* | ||
* @author Andrii Filippov | ||
* | ||
*/ | ||
|
||
@SuppressWarnings("restriction") | ||
@RunWith(SWTBotJunit4ClassRunner.class) | ||
@FixMethodOrder(MethodSorters.NAME_ASCENDING) | ||
public class IDFProjectJTAGFlashTest | ||
{ | ||
@BeforeClass | ||
public static void beforeTestClass() throws Exception | ||
{ | ||
Fixture.loadEnv(); | ||
} | ||
|
||
@After | ||
public void afterEachTest() | ||
{ | ||
try | ||
{ | ||
Fixture.cleanTestEnv(); | ||
} | ||
catch (Exception e) | ||
{ | ||
System.err.println("Error during cleanup: " + e.getMessage()); | ||
} | ||
} | ||
|
||
@Test | ||
public void givenNewProjectCreatedWhenSelectJTAGflashWhenBuiltThenCheckFlashedSuccessfully() throws Exception | ||
{ | ||
if (SystemUtils.IS_OS_LINUX) //temporary solution until new ESP boards arrive for Windows | ||
{ | ||
Fixture.givenNewEspressifIDFProjectIsSelected("EspressIf", "Espressif IDF Project"); | ||
Fixture.givenProjectNameIs("NewProjectJTAGFlashTest"); | ||
Fixture.whenNewProjectIsSelected(); | ||
Fixture.whenSelectJTAGflashInLaunchConfig(); | ||
Fixture.whenSelectLaunchTargetBoard(); | ||
Fixture.whenProjectIsBuiltUsingContextMenu(); | ||
Fixture.whenFlashProject(); | ||
Fixture.thenVerifyJTAGflashDone(); | ||
} | ||
else | ||
{ | ||
assertTrue(true); | ||
} | ||
} | ||
|
||
private static class Fixture | ||
{ | ||
private static SWTWorkbenchBot bot; | ||
private static String category; | ||
private static String subCategory; | ||
private static String projectName; | ||
|
||
private static void loadEnv() throws Exception | ||
{ | ||
bot = WorkBenchSWTBot.getBot(); | ||
EnvSetupOperations.setupEspressifEnv(bot); | ||
bot.sleep(1000); | ||
ProjectTestOperations.deleteAllProjects(bot); | ||
} | ||
|
||
private static void givenNewEspressifIDFProjectIsSelected(String category, String subCategory) | ||
{ | ||
Fixture.category = category; | ||
Fixture.subCategory = subCategory; | ||
} | ||
|
||
private static void givenProjectNameIs(String projectName) | ||
{ | ||
Fixture.projectName = projectName; | ||
} | ||
|
||
private static void whenNewProjectIsSelected() throws Exception | ||
{ | ||
ProjectTestOperations.setupProject(projectName, category, subCategory, bot); | ||
} | ||
|
||
private static void whenProjectIsBuiltUsingContextMenu() throws IOException | ||
{ | ||
ProjectTestOperations.buildProjectUsingContextMenu(projectName, bot); | ||
ProjectTestOperations.waitForProjectBuild(bot); | ||
TestWidgetWaitUtility.waitForOperationsInProgressToFinishAsync(bot); | ||
} | ||
|
||
private static void whenFlashProject() throws IOException | ||
{ | ||
ProjectTestOperations.launchCommandUsingContextMenu(projectName, bot, "Run Configurations..."); | ||
TestWidgetWaitUtility.waitForDialogToAppear(bot, "Run Configurations", 10000); | ||
bot.tree().getTreeItem("ESP-IDF Application").select(); | ||
bot.tree().getTreeItem("ESP-IDF Application").expand(); | ||
bot.tree().getTreeItem("ESP-IDF Application").getNode(projectName).select(); | ||
bot.waitUntil(widgetIsEnabled(bot.button("Run")), 5000); | ||
bot.button("Run").click(); | ||
} | ||
|
||
private static void whenSelectJTAGflashInLaunchConfig() throws Exception | ||
{ | ||
LaunchBarConfigSelector configSelector = new LaunchBarConfigSelector(bot); | ||
configSelector.clickEdit(); | ||
TestWidgetWaitUtility.waitForDialogToAppear(bot, "Edit Configuration", 20000); | ||
bot.cTabItem("Main").show(); | ||
bot.cTabItem("Main").setFocus(); | ||
bot.comboBoxWithLabel("Flash over:").setSelection("JTAG"); | ||
bot.button("OK").click(); | ||
} | ||
|
||
private static void whenSelectLaunchTargetBoard() throws Exception | ||
{ | ||
LaunchBarTargetSelector targetSelector = new LaunchBarTargetSelector(bot); | ||
targetSelector.clickEdit(); | ||
TestWidgetWaitUtility.waitForDialogToAppear(bot, "New ESP Target", 20000); | ||
SWTBotShell shell = bot.shell("New ESP Target"); | ||
bot.comboBoxWithLabel("Board:").setSelection("ESP32-ETHERNET-KIT [usb://1-10]"); | ||
TestWidgetWaitUtility.waitForOperationsInProgressToFinishSync(bot); | ||
shell.setFocus(); | ||
bot.button("Finish").click(); | ||
} | ||
|
||
private static void thenVerifyJTAGflashDone() throws Exception | ||
{ | ||
ProjectTestOperations.verifyTheConsoleOutput(bot, "** Flashing done for partition_table/partition-table.bin"); | ||
} | ||
|
||
private static void cleanTestEnv() | ||
{ | ||
TestWidgetWaitUtility.waitForOperationsInProgressToFinishAsync(bot); | ||
ProjectTestOperations.closeAllProjects(bot); | ||
ProjectTestOperations.deleteAllProjects(bot); | ||
} | ||
} | ||
} |
This file contains hidden or 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
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.