-
Notifications
You must be signed in to change notification settings - Fork 133
SWTBot test case: Launch Target editor verification #1304
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
+308
−22
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
17be7b0
ci: add test case 'The change of the target is responded to with a po…
AndriiFilippov 0bfddae
ci: add test case 'Creation of NEW Launch Target'
AndriiFilippov e5dcc06
ci: improve wait logic for 'Next >' button
AndriiFilippov 268a097
ci: improve Project Build method with try catch logic
AndriiFilippov b25b8f4
ci: add assertion logic
AndriiFilippov d1708c7
ci: add third test
AndriiFilippov c4f6b9b
ci: add 'Delete target' test
AndriiFilippov ed7867a
ci: implement 'ScrollToBottom' method for better search in Launch Tar…
AndriiFilippov 01bba94
fix: optimize tests execution logic
AndriiFilippov b0777d5
fix: optimize tests logic
AndriiFilippov 82303cc
fix: remove unused imports
AndriiFilippov 744cb38
fix: improve isTargetPresent method logic
AndriiFilippov 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
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
225 changes: 225 additions & 0 deletions
225
...f/idf/ui/test/executable/cases/project/IDFProjectLaunchTargetEditorFunctionalityTest.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,225 @@ | ||
| /******************************************************************************* | ||
| * 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 static org.eclipse.swtbot.swt.finder.waits.Conditions.widgetIsEnabled; | ||
| import static org.junit.Assert.assertTrue; | ||
|
|
||
| import java.io.IOException; | ||
|
|
||
| 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.AfterClass; | ||
| 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.handlers.Messages; | ||
| import com.espressif.idf.ui.test.common.WorkBenchSWTBot; | ||
| 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.LaunchBarTargetSelector; | ||
|
|
||
| /** | ||
| * Test class to test the Launch Target Editor | ||
| * | ||
| * @author Andrii Filippov | ||
| * | ||
| */ | ||
| @SuppressWarnings("restriction") | ||
| @RunWith(SWTBotJunit4ClassRunner.class) | ||
| @FixMethodOrder(MethodSorters.NAME_ASCENDING) | ||
|
|
||
| public class IDFProjectLaunchTargetEditorFunctionalityTest { | ||
| @BeforeClass | ||
| public static void beforeTestClass() throws Exception | ||
| { | ||
| Fixture.loadEnv(); | ||
| Fixture.givenNewEspressifIDFProjectIsSelected("EspressIf", "Espressif IDF Project"); | ||
| Fixture.givenProjectNameIs("LaunchTargetEditorTest"); | ||
| Fixture.whenNewProjectIsSelected(); | ||
| } | ||
|
|
||
| @AfterClass | ||
| public static void afterEachTest() | ||
| { | ||
| try | ||
| { | ||
| Fixture.cleanTestEnv(); | ||
| } | ||
| catch (Exception e) | ||
| { | ||
| System.err.println("Error during cleanup: " + e.getMessage()); | ||
| } | ||
| } | ||
|
|
||
| @Test | ||
| public void givenANewProjectCreatedBuiltWhenSelectNewTargetWhenPopUpAppearsThenBuildFolderDeletedSuccessfully() | ||
| throws Exception | ||
| { | ||
| Fixture.whenProjectIsBuiltUsingContextMenu(); | ||
| Fixture.whenChangeLaunchTarget(); | ||
| Fixture.whenRefreshProject(); | ||
| Fixture.thenBuildFolderDeletedSuccessfully(); | ||
| } | ||
|
|
||
| @Test | ||
| public void givenBNewProjectCreatedWhenCreateNewLaunchTargetThenProjectBuiltSuccessfully() | ||
| throws Exception | ||
| { | ||
| Fixture.whenCreateNewLaunchTarget(); | ||
| Fixture.whenProjectIsBuiltUsingContextMenu(); | ||
| } | ||
|
|
||
| @Test | ||
| public void givenCNewProjectCreatedWhenDeleteSelectedLaunchTargetThenDeletedSuccessfully() | ||
| throws Exception | ||
| { | ||
| Fixture.whenProjectFullCleanUsingContextMenu(); | ||
| Fixture.whenDeleteSelectedLaunchTarget(); | ||
| Fixture.thenLaunchTargetDeletedSuccessfully(); | ||
| } | ||
|
|
||
| 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 whenChangeLaunchTarget() throws Exception | ||
| { | ||
| LaunchBarTargetSelector targetSelector = new LaunchBarTargetSelector(bot); | ||
| targetSelector.selectTarget("esp32c2"); | ||
| TestWidgetWaitUtility.waitForDialogToAppear(bot, "IDF Launch Target Changed", 20000); | ||
| SWTBotShell shell = bot.shell("IDF Launch Target Changed"); | ||
| shell.setFocus(); | ||
| bot.button("Yes").click(); | ||
| } | ||
AndriiFilippov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| private static void whenSelectLaunchTarget() throws Exception | ||
| { | ||
| LaunchBarTargetSelector targetSelector = new LaunchBarTargetSelector(bot); | ||
| targetSelector.selectTarget("target"); | ||
| } | ||
|
|
||
| private static void whenDeleteLaunchTarget() throws Exception | ||
| { | ||
| bot.sleep(500); | ||
| LaunchBarTargetSelector targetSelector = new LaunchBarTargetSelector(bot); | ||
| targetSelector.clickEdit(); | ||
| TestWidgetWaitUtility.waitForDialogToAppear(bot, "New ESP Target", 20000); | ||
| SWTBotShell shell = bot.shell("New ESP Target"); | ||
| shell.setFocus(); | ||
| bot.button("Delete").click(); | ||
| } | ||
|
|
||
| private static void whenDeleteSelectedLaunchTarget() throws Exception | ||
| { | ||
| whenSelectLaunchTarget(); | ||
| whenDeleteLaunchTarget(); | ||
| } | ||
|
|
||
| private static void thenLaunchTargetDeletedSuccessfully() throws Exception | ||
| { | ||
| bot.sleep(500); | ||
| LaunchBarTargetSelector targetSelector = new LaunchBarTargetSelector(bot); | ||
| assertTrue("Launch Target was not deleted successfully!", !targetSelector.isTargetPresent("target")); | ||
| } | ||
|
|
||
| private static void selectNewLaunchTarget() | ||
| { | ||
| LaunchBarTargetSelector targetSelector = new LaunchBarTargetSelector(bot); | ||
| targetSelector.select("New Launch Target..."); | ||
| TestWidgetWaitUtility.waitForDialogToAppear(bot, "New Launch Target", 20000); | ||
| assertTrue("'New Launch Target' dialog did not appear", bot.shell("New Launch Target").isActive()); | ||
| } | ||
|
|
||
| private static void handleNewLaunchTargetDialog() throws Exception | ||
| { | ||
| SWTBotShell shell = bot.shell("New Launch Target"); | ||
| bot.table().select("ESP Target"); | ||
| shell.setFocus(); | ||
| bot.waitUntil(widgetIsEnabled(bot.button("Next >")), 5000); | ||
| bot.button("Next >").click(); | ||
| TestWidgetWaitUtility.waitForDialogToAppear(bot, "New ESP Target",10000); | ||
| } | ||
|
|
||
| private static void handleNewEspTargetDialog() throws Exception | ||
| { | ||
| bot.textWithLabel("Name:").setText("target"); | ||
| bot.button("Finish").click(); | ||
| TestWidgetWaitUtility.waitForOperationsInProgressToFinishSync(bot); | ||
| } | ||
|
|
||
| private static void whenCreateNewLaunchTarget() throws Exception | ||
| { | ||
| selectNewLaunchTarget(); | ||
| handleNewLaunchTargetDialog(); | ||
| handleNewEspTargetDialog(); | ||
| } | ||
|
|
||
| private static void whenRefreshProject() throws IOException | ||
| { | ||
| ProjectTestOperations.launchCommandUsingContextMenu(projectName, bot, "Refresh"); | ||
| } | ||
AndriiFilippov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| private static void thenBuildFolderDeletedSuccessfully() throws Exception | ||
| { | ||
| assertTrue("Build folder was not deleted successfully!", ProjectTestOperations.findProjectFullCleanedFilesInBuildFolder(projectName, bot)); | ||
| } | ||
|
|
||
| private static void whenProjectFullCleanUsingContextMenu() throws IOException | ||
| { | ||
| ProjectTestOperations.launchCommandUsingContextMenu(projectName, bot, "Project Full Clean"); | ||
| ProjectTestOperations.joinJobByName(Messages.ProjectFullCleanCommandHandler_RunningFullcleanJobName); | ||
| ProjectTestOperations.findInConsole(bot, "Espressif IDF Tools Console", "Done"); | ||
| TestWidgetWaitUtility.waitForOperationsInProgressToFinishSync(bot); | ||
| } | ||
|
|
||
| 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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought we weren’t able to find dialogs created with MessageDialog.openQuestion. Last time I checked in the 4.0 PR, I couldn’t find any dialogs created with this method. We should revisit this for the 4.0.0 part—maybe the difference lies in how we pass the shell to the dialog. For example, in the
IDF Launch Target Changeddialog, we are using EclipseUtil.getShell().There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If its working on runner with green builds which I am not seeing we can use it and see what is causing this issue and fix that