Skip to content

Commit 1b0a16a

Browse files
fix: updated Clangd test case based on latest changes
1 parent a93af6e commit 1b0a16a

File tree

1 file changed

+21
-49
lines changed

1 file changed

+21
-49
lines changed

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

Lines changed: 21 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
1818
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
1919
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
20-
import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
2120
import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
2221
import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
2322
import org.junit.After;
@@ -32,7 +31,6 @@
3231
import com.espressif.idf.ui.test.common.utility.TestWidgetWaitUtility;
3332
import com.espressif.idf.ui.test.operations.EnvSetupOperations;
3433
import com.espressif.idf.ui.test.operations.ProjectTestOperations;
35-
import com.espressif.idf.ui.test.operations.selectors.LaunchBarTargetSelector;
3634

3735
/**
3836
* Test class to test Clangd / Clang-Format files functionality
@@ -125,15 +123,11 @@ public void givenNewProjectsAreCreatedAndBuiltWhenPreferencesOpenedThenClangdArg
125123
}
126124

127125
@Test
128-
public void givenNewProjectIsCreatedWhenBuiltThenClangdDriversUpdateOnTargetWhenChangeTargetAndBuiltThenClangdDriversUpdateOnTargetChange()
129-
throws Exception
126+
public void givenNewProjectIsCreatedThenClangdAndQueryDriversPathsAreUpdated() throws Exception
130127
{
131128
Fixture.givenNewProjectIsCreated("NewProjectClangFilesTest6");
132-
Fixture.whenProjectIsBuiltUsingContextMenu("NewProjectClangFilesTest6");
133-
Fixture.thenClangdDriversUpdateOnSelectedTarget();
134-
Fixture.whenChangeTarget();
135-
Fixture.whenProjectIsBuiltUsingContextMenu("NewProjectClangFilesTest6");
136-
Fixture.thenClangdDriversUpdateOnSelectedTarget();
129+
Fixture.thenClangdPathUpdateOnSelectedTarget();
130+
Fixture.thenQueryDriversUpdateOnSelectedTarget();
137131
}
138132

139133
private static class Fixture
@@ -142,22 +136,13 @@ private static class Fixture
142136
private static String category;
143137
private static String subCategory;
144138
private static String projectName;
145-
private static LaunchBarTargetSelector launchBarTargetSelector;
146139

147140
private static void loadEnv() throws Exception
148141
{
149142
bot = WorkBenchSWTBot.getBot();
150143
EnvSetupOperations.setupEspressifEnv(bot);
151144
bot.sleep(1000);
152145
ProjectTestOperations.deleteAllProjects(bot);
153-
try
154-
{
155-
launchBarTargetSelector = new LaunchBarTargetSelector(bot);
156-
}
157-
catch (WidgetNotFoundException e)
158-
{
159-
launchBarTargetSelector = new LaunchBarTargetSelector(bot, false);
160-
}
161146
}
162147

163148
private static void givenNewEspressifIDFProjectIsSelected(String category, String subCategory)
@@ -197,17 +182,16 @@ private static void whenNewProjectIsSelected(String projectName) throws Exceptio
197182
bot.sleep(1000);
198183
}
199184

200-
private static void thenClangdDriversUpdateOnSelectedTarget() throws Exception
185+
private static void thenClangdPathUpdateOnSelectedTarget() throws Exception
201186
{
202187
whenOpenClangdPreferences();
203-
thenCompareActualClangdDriversWithExpected("NewProjectClangFilesTest6");
204-
closePreferencesDialog();
188+
thenCompareActualClangdPathWithExpected("NewProjectClangFilesTest6");
205189
}
206190

207-
private static void whenChangeTarget() throws Exception
191+
private static void thenQueryDriversUpdateOnSelectedTarget() throws Exception
208192
{
209-
Fixture.thenLaunchTargetIsSelectedFromLaunchTargets("esp32s2");
210-
Fixture.closeTargetDialog();
193+
thenCompareActualQueryDriversWithExpected("NewProjectClangFilesTest6");
194+
closePreferencesDialog();
211195
}
212196

213197
private static void thenClangdFileIsPresent() throws IOException
@@ -282,11 +266,6 @@ private static void thenClangdFileContentCheckedAgain(String projectName) throws
282266
"CompileFlags:\n" + " CompilationDatabase: " + buildPath + "\n" + " Remove: [-m*, -f*]", bot));
283267
}
284268

285-
public static void thenLaunchTargetIsSelectedFromLaunchTargets(String launchTargetName)
286-
{
287-
launchBarTargetSelector.select(launchTargetName);
288-
}
289-
290269
private static void thenClangFormatContentChecked() throws Exception
291270
{
292271
bot.cTabItem(".clang-format").activate();
@@ -410,13 +389,6 @@ private static String getExpectedBuildFolderPATHforClangdAdditionalArgument(Stri
410389
}
411390
}
412391

413-
private static String getXtensaToolchainPathBasedOnTheTargetConfigured() throws IOException
414-
{
415-
String toolchain = IDFUtil.getToolchainExePathForActiveTarget();
416-
Path toolchainPath = Paths.get(toolchain);
417-
return toolchainPath.toAbsolutePath().toString();
418-
}
419-
420392
private static void thenCompareActualClangdArgumentWithExpected(String projectName) throws IOException
421393
{
422394
SWTBotShell prefrencesShell = bot.shell("Preferences");
@@ -425,12 +397,20 @@ private static void thenCompareActualClangdArgumentWithExpected(String projectNa
425397
assertTrue(expectedClangdPath.equals(actualClangdPath));
426398
}
427399

428-
private static void thenCompareActualClangdDriversWithExpected(String projectName) throws IOException
400+
private static void thenCompareActualQueryDriversWithExpected(String projectName) throws IOException
401+
{
402+
SWTBotShell prefrencesShell = bot.shell("Preferences");
403+
String actualQueryDriversPath = prefrencesShell.bot().textWithLabel("Drivers").getText();
404+
String expectedQueryDriversPath = "**";
405+
assertEquals(expectedQueryDriversPath, actualQueryDriversPath);
406+
}
407+
408+
private static void thenCompareActualClangdPathWithExpected(String projectName) throws IOException
429409
{
430410
SWTBotShell prefrencesShell = bot.shell("Preferences");
431-
String actualDriversPath = prefrencesShell.bot().textWithLabel("Drivers").getText();
432-
String expectedDriversPath = "**";
433-
assertEquals(expectedDriversPath, actualDriversPath);
411+
String actualClangdPath = prefrencesShell.bot().textWithLabel("Path").getText();
412+
String expectedClangdPath = "bin";
413+
assertTrue(actualClangdPath.contains(expectedClangdPath));
434414
}
435415

436416
private static void whenProjectIsBuiltUsingContextMenu(String projectName) throws IOException
@@ -454,18 +434,10 @@ private static void whenOpenClangdPreferences() throws Exception
454434
private static void closePreferencesDialog()
455435
{
456436
SWTBotShell preferencesShell = bot.shell("Preferences");
457-
preferencesShell.bot().button("Cancel").click(); // Or "Apply and Close"
437+
preferencesShell.bot().button("Cancel").click();
458438
TestWidgetWaitUtility.waitWhileDialogIsVisible(bot, "Preferences", 10000);
459439
}
460440

461-
private static void closeTargetDialog()
462-
{
463-
TestWidgetWaitUtility.waitForDialogToAppear(bot, "IDF Launch Target Changed", 10000);
464-
SWTBotShell preferencesShell = bot.shell("IDF Launch Target Changed");
465-
preferencesShell.bot().button("Yes").click(); // Or "Apply and Close"
466-
TestWidgetWaitUtility.waitWhileDialogIsVisible(bot, "IDF Launch Target Changed", 10000);
467-
}
468-
469441
private static void cleanTestEnv()
470442
{
471443
TestWidgetWaitUtility.waitForOperationsInProgressToFinishAsync(bot);

0 commit comments

Comments
 (0)