diff --git a/tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/common/utility/TestWidgetWaitUtility.java b/tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/common/utility/TestWidgetWaitUtility.java index f0144b80c..1cc1a4d5a 100644 --- a/tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/common/utility/TestWidgetWaitUtility.java +++ b/tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/common/utility/TestWidgetWaitUtility.java @@ -277,7 +277,14 @@ public static void waitForCTabToAppear(SWTWorkbenchBot workbenchBot, String tabN @Override public boolean test() throws Exception { - return workbenchBot.cTabItem(tabName).isActive(); + try + { + return workbenchBot.cTabItem(tabName) != null; + } + catch (WidgetNotFoundException e) + { + return false; + } } @Override diff --git a/tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/IDFProjectLspCdtFunctionalityTest.java b/tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/IDFProjectLspCdtFunctionalityTest.java index fc1da8504..cab910a29 100644 --- a/tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/IDFProjectLspCdtFunctionalityTest.java +++ b/tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/IDFProjectLspCdtFunctionalityTest.java @@ -48,9 +48,10 @@ public static void setupEnv() throws Exception bot = WorkBenchSWTBot.getBot(); EnvSetupOperations.setupEspressifEnv(bot); ProjectTestOperations.deleteAllProjects(bot); - ProjectTestOperations.setupProjectWithReconfigureCommand(PROJECT_NAME, "EspressIf", "Espressif IDF Project", //$NON-NLS-1$ //$NON-NLS-2$ - bot); - TestWidgetWaitUtility.waitForOperationsInProgressToFinishSync(bot); + ProjectTestOperations.setupProject(PROJECT_NAME, "EspressIf", "Espressif IDF Project", bot); + ProjectTestOperations.buildProjectUsingContextMenu(PROJECT_NAME, bot); + ProjectTestOperations.waitForProjectBuild(bot); + TestWidgetWaitUtility.waitForOperationsInProgressToFinishAsync(bot); } @AfterClass diff --git a/tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectClangFilesTest.java b/tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectClangFilesTest.java index 32e048cf2..a4783e4ef 100644 --- a/tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectClangFilesTest.java +++ b/tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectClangFilesTest.java @@ -4,9 +4,9 @@ *******************************************************************************/ package com.espressif.idf.ui.test.executable.cases.project; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -import java.io.File; import java.io.IOException; import java.nio.file.Path; import java.nio.file.Paths; @@ -14,7 +14,6 @@ import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor; import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView; @@ -28,13 +27,11 @@ import org.junit.runner.RunWith; import org.junit.runners.MethodSorters; -import com.espressif.idf.core.IDFConstants; import com.espressif.idf.core.util.IDFUtil; 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.LaunchBarConfigSelector; import com.espressif.idf.ui.test.operations.selectors.LaunchBarTargetSelector; /** @@ -116,7 +113,8 @@ public void givenNewProjectIsCreatedThenTestClangFormatFileSettingsAreBeingAppli } @Test - public void givenNewProjectsAreCreatedAndBuiltWhenPreferencesOpenedThenClangdArgumentMatchesExpected() throws Exception + public void givenNewProjectsAreCreatedAndBuiltWhenPreferencesOpenedThenClangdArgumentMatchesExpected() + throws Exception { Fixture.givenNewProjectIsCreated("NewProjectClangFilesTest4"); Fixture.whenProjectIsBuiltUsingContextMenu("NewProjectClangFilesTest4"); @@ -127,7 +125,8 @@ public void givenNewProjectsAreCreatedAndBuiltWhenPreferencesOpenedThenClangdArg } @Test - public void givenNewProjectIsCreatedWhenBuiltThenClangdDriversUpdateOnTargetWhenChangeTargetAndBuiltThenClangdDriversUpdateOnTargetChange() throws Exception + public void givenNewProjectIsCreatedWhenBuiltThenClangdDriversUpdateOnTargetWhenChangeTargetAndBuiltThenClangdDriversUpdateOnTargetChange() + throws Exception { Fixture.givenNewProjectIsCreated("NewProjectClangFilesTest6"); Fixture.whenProjectIsBuiltUsingContextMenu("NewProjectClangFilesTest6"); @@ -186,7 +185,7 @@ private static void thenCheckClangdArgumentAfterProjectBuilt(String projectName) Fixture.closePreferencesDialog(); } - private static void whenNewProjectIsSelected( String projectName) throws Exception + private static void whenNewProjectIsSelected(String projectName) throws Exception { ProjectTestOperations.setupProject(projectName, category, subCategory, bot); TestWidgetWaitUtility.waitForOperationsInProgressToFinishSync(bot); @@ -255,14 +254,17 @@ private static void whenClangFormatFileOpenedUsingDoubleClick() throws IOExcepti private static String getExpectedBuildFolderPATH(String projectName) throws IOException { - try { - IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); - String buildFolder = IDFUtil.getBuildDir(project); - Path buildFolderPath = Paths.get(buildFolder); - return buildFolderPath.toAbsolutePath().toString(); - } catch (CoreException e) { - throw new IOException("Failed to get build directory for project: " + projectName, e); - } + try + { + IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); + String buildFolder = IDFUtil.getBuildDir(project); + Path buildFolderPath = Paths.get(buildFolder); + return buildFolderPath.toAbsolutePath().toString(); + } + catch (CoreException e) + { + throw new IOException("Failed to get build directory for project: " + projectName, e); + } } private static void thenClangdFileContentChecked() throws Exception @@ -290,31 +292,32 @@ private static void thenClangFormatContentChecked() throws Exception bot.cTabItem(".clang-format").activate(); assertTrue(ProjectTestOperations.checkExactMatchInTextEditor( """ - # We'll use defaults from the LLVM style, but with some modifications so that it's close to the CDT K&R style. - BasedOnStyle: LLVM - UseTab: Always - IndentWidth: 4 - TabWidth: 4 - BreakConstructorInitializers: AfterColon - IndentAccessModifiers: false - AccessModifierOffset: -4 - """, + # We'll use defaults from the LLVM style, but with some modifications so that it's close to the CDT K&R style. + BasedOnStyle: LLVM + UseTab: Always + IndentWidth: 4 + TabWidth: 4 + BreakConstructorInitializers: AfterColon + IndentAccessModifiers: false + AccessModifierOffset: -4 + """, bot)); } private static void thenClangFormatContentEdited() throws Exception { SWTBotEditor textEditor = bot.activeEditor(); - textEditor.toTextEditor().setText(""" - # We'll use defaults from the LLVM style, but with some modifications so that it's close to the CDT K&R style. - BasedOnStyle: LLVM - UseTab: Always - IndentWidth: 0 - TabWidth: 0 - BreakConstructorInitializers: AfterColon - IndentAccessModifiers: false - AccessModifierOffset: -4 - """); + textEditor.toTextEditor().setText( + """ + # We'll use defaults from the LLVM style, but with some modifications so that it's close to the CDT K&R style. + BasedOnStyle: LLVM + UseTab: Always + IndentWidth: 0 + TabWidth: 0 + BreakConstructorInitializers: AfterColon + IndentAccessModifiers: false + AccessModifierOffset: -4 + """); } private static void addSpaceToMainFile() throws Exception @@ -391,39 +394,43 @@ private static void thenMainFileShellClosed() throws IOException bot.shell("Save Resource").bot().button("Save").click(); } - private static String getExpectedBuildFolderPATHforClangdAdditionalArgument(String projectName) throws IOException + private static String getExpectedBuildFolderPATHforClangdAdditionalArgument(String projectName) + throws IOException { - try { - IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); - String buildFolder = IDFUtil.getBuildDir(project); - Path buildFolderPath = Paths.get(buildFolder); - return "--compile-commands-dir=" + buildFolderPath.toAbsolutePath().toString(); - } catch (CoreException e) { - throw new IOException("Failed to get build directory for project: " + projectName, e); - } + try + { + IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); + String buildFolder = IDFUtil.getBuildDir(project); + Path buildFolderPath = Paths.get(buildFolder); + return "--compile-commands-dir=" + buildFolderPath.toAbsolutePath().toString(); + } + catch (CoreException e) + { + throw new IOException("Failed to get build directory for project: " + projectName, e); + } } private static String getXtensaToolchainPathBasedOnTheTargetConfigured() throws IOException { - String toolchain = IDFUtil.getToolchainExePathForActiveTarget(); + String toolchain = IDFUtil.getToolchainExePathForActiveTarget(); Path toolchainPath = Paths.get(toolchain); return toolchainPath.toAbsolutePath().toString(); } private static void thenCompareActualClangdArgumentWithExpected(String projectName) throws IOException - { - SWTBotShell prefrencesShell = bot.shell("Preferences"); - String actualClangdPath = prefrencesShell.bot().textWithLabel("Additional").getText(); - String expectedClangdPath = getExpectedBuildFolderPATHforClangdAdditionalArgument(projectName); - assertTrue(expectedClangdPath.equals(actualClangdPath)); + { + SWTBotShell prefrencesShell = bot.shell("Preferences"); + String actualClangdPath = prefrencesShell.bot().textWithLabel("Additional").getText(); + String expectedClangdPath = getExpectedBuildFolderPATHforClangdAdditionalArgument(projectName); + assertTrue(expectedClangdPath.equals(actualClangdPath)); } private static void thenCompareActualClangdDriversWithExpected(String projectName) throws IOException - { - SWTBotShell prefrencesShell = bot.shell("Preferences"); - String actualClangdPath = prefrencesShell.bot().textWithLabel("Drivers").getText(); - String expectedClangdPath = getXtensaToolchainPathBasedOnTheTargetConfigured(); - assertTrue(expectedClangdPath.equals(actualClangdPath)); + { + SWTBotShell prefrencesShell = bot.shell("Preferences"); + String actualDriversPath = prefrencesShell.bot().textWithLabel("Drivers").getText(); + String expectedDriversPath = "**"; + assertEquals(expectedDriversPath, actualDriversPath); } private static void whenProjectIsBuiltUsingContextMenu(String projectName) throws IOException @@ -444,17 +451,19 @@ private static void whenOpenClangdPreferences() throws Exception prefrencesShell.bot().tree().getTreeItem("C/C++").getNode("Editor (LSP)").getNode("clangd").select(); } - private static void closePreferencesDialog() { - SWTBotShell preferencesShell = bot.shell("Preferences"); - preferencesShell.bot().button("Cancel").click(); // Or "Apply and Close" - TestWidgetWaitUtility.waitWhileDialogIsVisible(bot, "Preferences", 10000); + private static void closePreferencesDialog() + { + SWTBotShell preferencesShell = bot.shell("Preferences"); + preferencesShell.bot().button("Cancel").click(); // Or "Apply and Close" + TestWidgetWaitUtility.waitWhileDialogIsVisible(bot, "Preferences", 10000); } - private static void closeTargetDialog() { + private static void closeTargetDialog() + { TestWidgetWaitUtility.waitForDialogToAppear(bot, "IDF Launch Target Changed", 10000); - SWTBotShell preferencesShell = bot.shell("IDF Launch Target Changed"); - preferencesShell.bot().button("Yes").click(); // Or "Apply and Close" - TestWidgetWaitUtility.waitWhileDialogIsVisible(bot, "IDF Launch Target Changed", 10000); + SWTBotShell preferencesShell = bot.shell("IDF Launch Target Changed"); + preferencesShell.bot().button("Yes").click(); // Or "Apply and Close" + TestWidgetWaitUtility.waitWhileDialogIsVisible(bot, "IDF Launch Target Changed", 10000); } private static void cleanTestEnv() diff --git a/tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectSDKconfigTest.java b/tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectSDKconfigTest.java index 0d3251443..ed891fbd6 100644 --- a/tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectSDKconfigTest.java +++ b/tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectSDKconfigTest.java @@ -172,26 +172,26 @@ private static void whenProjectIsBuiltUsingContextMenu() throws IOException private static void thenSDKconfigFileIsPresent() throws IOException { - assertTrue(bot.tree().getTreeItem(projectName).getNode("sdkconfig") != null); + assertTrue("SDKconfig file was not found", bot.tree().getTreeItem(projectName).getNode("sdkconfig") != null); } private static void thenSDKconfigFileIsAbsent() throws IOException { - assertTrue(!bot.tree().getTreeItem(projectName).getNodes().contains("sdkconfig")); + assertTrue("SDKconfig file is still present",!bot.tree().getTreeItem(projectName).getNodes().contains("sdkconfig")); } private static void whenSDKconfigFileOpenedUsingDoubleClick() throws IOException { bot.tree().getTreeItem(projectName).getNode("sdkconfig").doubleClick(); TestWidgetWaitUtility.waitWhileDialogIsVisible(bot, "Progress Information", 40000); - TestWidgetWaitUtility.waitForCTabToAppear(bot, "SDK Configuration (sdkconfig)", 5000); + TestWidgetWaitUtility.waitForCTabToAppear(bot, "SDK Configuration (sdkconfig)", 10000); } private static void whenSDKconfigFileOpenedUsingContextMenu() throws IOException { ProjectTestOperations.launchCommandUsingContextMenu(projectName, bot, "Menu Config"); TestWidgetWaitUtility.waitWhileDialogIsVisible(bot, "Progress Information", 40000); - TestWidgetWaitUtility.waitForCTabToAppear(bot, "SDK Configuration (sdkconfig)", 5000); + TestWidgetWaitUtility.waitForCTabToAppear(bot, "SDK Configuration (sdkconfig)", 10000); } private static void thenSDKconfigFileContentChecked() throws Exception @@ -200,7 +200,7 @@ private static void thenSDKconfigFileContentChecked() throws Exception TestWidgetWaitUtility.waitForTreeItem("Partition Table", bot.tree(1), bot); bot.tree(1).getTreeItem("Partition Table").click(); bot.sleep(1000); - assertTrue(bot.textWithLabel("Offset of partition table (hex)").getText().matches("0x8000")); + assertTrue("'Offset of partition table (hex)' does not match '0x8000'", bot.textWithLabel("Offset of partition table (hex)").getText().matches("0x8000")); } private static void thenSDKconfigFileContentEdited() throws Exception @@ -210,9 +210,9 @@ private static void thenSDKconfigFileContentEdited() throws Exception bot.tree(1).getTreeItem("Partition Table").click(); bot.sleep(1000); bot.textWithLabel("Offset of partition table (hex)").setText("0x4000"); - bot.sleep(2000); + bot.sleep(1000); bot.comboBoxWithLabel("Partition Table").setSelection("Custom partition table CSV"); - bot.sleep(2000); + bot.sleep(1000); bot.checkBox("Generate an MD5 checksum for the partition table").click(); } @@ -225,8 +225,7 @@ private static void whenSDKconfigFileIsSaved() throws IOException { bot.cTabItem("*SDK Configuration (sdkconfig)").activate(); bot.cTabItem("*SDK Configuration (sdkconfig)").close(); - bot.sleep(5000); - TestWidgetWaitUtility.waitForDialogToAppear(bot, "Save Resource", 5000); + TestWidgetWaitUtility.waitForDialogToAppear(bot, "Save Resource", 10000); bot.shell("Save Resource").bot().button("Save").click(); } @@ -235,12 +234,12 @@ private static void thenCheckChangesAreSaved() throws Exception bot.cTabItem("SDK Configuration (sdkconfig)").activate(); TestWidgetWaitUtility.waitForTreeItem("Partition Table", bot.tree(1), bot); bot.tree(1).getTreeItem("Partition Table").click(); - bot.sleep(2000); - assertTrue(bot.textWithLabel("Offset of partition table (hex)").getText().matches("0x4000")); - bot.sleep(2000); - assertTrue(bot.comboBoxWithLabel("Partition Table").selection().equals("Custom partition table CSV")); - bot.sleep(2000); - assertTrue(!bot.checkBox("Generate an MD5 checksum for the partition table").isChecked()); + bot.sleep(1000); + assertTrue("'Offset of partition table (hex)' does not match '0x4000'", bot.textWithLabel("Offset of partition table (hex)").getText().matches("0x4000")); + bot.sleep(1000); + assertTrue("'Partition Table' does not match 'Custom partition table CSV'", bot.comboBoxWithLabel("Partition Table").selection().equals("Custom partition table CSV")); + bot.sleep(1000); + assertTrue("'Generate an MD5 checksum for the partition table' checkbox is still checked!", !bot.checkBox("Generate an MD5 checksum for the partition table").isChecked()); } private static void cleanTestEnv()