44*******************************************************************************/
55package com .espressif .idf .ui .test .executable .cases .project ;
66
7+ import static org .junit .Assert .assertEquals ;
78import static org .junit .Assert .assertTrue ;
89
9- import java .io .File ;
1010import java .io .IOException ;
1111import java .nio .file .Path ;
1212import java .nio .file .Paths ;
1313
1414import org .eclipse .core .resources .IProject ;
1515import org .eclipse .core .resources .ResourcesPlugin ;
1616import org .eclipse .core .runtime .CoreException ;
17- import org .eclipse .core .runtime .IPath ;
1817import org .eclipse .swtbot .eclipse .finder .SWTWorkbenchBot ;
1918import org .eclipse .swtbot .eclipse .finder .widgets .SWTBotEditor ;
2019import org .eclipse .swtbot .eclipse .finder .widgets .SWTBotView ;
2827import org .junit .runner .RunWith ;
2928import org .junit .runners .MethodSorters ;
3029
31- import com .espressif .idf .core .IDFConstants ;
3230import com .espressif .idf .core .util .IDFUtil ;
3331import com .espressif .idf .ui .test .common .WorkBenchSWTBot ;
3432import com .espressif .idf .ui .test .common .utility .TestWidgetWaitUtility ;
3533import com .espressif .idf .ui .test .operations .EnvSetupOperations ;
3634import com .espressif .idf .ui .test .operations .ProjectTestOperations ;
37- import com .espressif .idf .ui .test .operations .selectors .LaunchBarConfigSelector ;
3835import com .espressif .idf .ui .test .operations .selectors .LaunchBarTargetSelector ;
3936
4037/**
@@ -116,7 +113,8 @@ public void givenNewProjectIsCreatedThenTestClangFormatFileSettingsAreBeingAppli
116113 }
117114
118115 @ Test
119- public void givenNewProjectsAreCreatedAndBuiltWhenPreferencesOpenedThenClangdArgumentMatchesExpected () throws Exception
116+ public void givenNewProjectsAreCreatedAndBuiltWhenPreferencesOpenedThenClangdArgumentMatchesExpected ()
117+ throws Exception
120118 {
121119 Fixture .givenNewProjectIsCreated ("NewProjectClangFilesTest4" );
122120 Fixture .whenProjectIsBuiltUsingContextMenu ("NewProjectClangFilesTest4" );
@@ -127,7 +125,8 @@ public void givenNewProjectsAreCreatedAndBuiltWhenPreferencesOpenedThenClangdArg
127125 }
128126
129127 @ Test
130- public void givenNewProjectIsCreatedWhenBuiltThenClangdDriversUpdateOnTargetWhenChangeTargetAndBuiltThenClangdDriversUpdateOnTargetChange () throws Exception
128+ public void givenNewProjectIsCreatedWhenBuiltThenClangdDriversUpdateOnTargetWhenChangeTargetAndBuiltThenClangdDriversUpdateOnTargetChange ()
129+ throws Exception
131130 {
132131 Fixture .givenNewProjectIsCreated ("NewProjectClangFilesTest6" );
133132 Fixture .whenProjectIsBuiltUsingContextMenu ("NewProjectClangFilesTest6" );
@@ -186,7 +185,7 @@ private static void thenCheckClangdArgumentAfterProjectBuilt(String projectName)
186185 Fixture .closePreferencesDialog ();
187186 }
188187
189- private static void whenNewProjectIsSelected ( String projectName ) throws Exception
188+ private static void whenNewProjectIsSelected (String projectName ) throws Exception
190189 {
191190 ProjectTestOperations .setupProject (projectName , category , subCategory , bot );
192191 TestWidgetWaitUtility .waitForOperationsInProgressToFinishSync (bot );
@@ -255,14 +254,17 @@ private static void whenClangFormatFileOpenedUsingDoubleClick() throws IOExcepti
255254
256255 private static String getExpectedBuildFolderPATH (String projectName ) throws IOException
257256 {
258- try {
259- IProject project = ResourcesPlugin .getWorkspace ().getRoot ().getProject (projectName );
260- String buildFolder = IDFUtil .getBuildDir (project );
261- Path buildFolderPath = Paths .get (buildFolder );
262- return buildFolderPath .toAbsolutePath ().toString ();
263- } catch (CoreException e ) {
264- throw new IOException ("Failed to get build directory for project: " + projectName , e );
265- }
257+ try
258+ {
259+ IProject project = ResourcesPlugin .getWorkspace ().getRoot ().getProject (projectName );
260+ String buildFolder = IDFUtil .getBuildDir (project );
261+ Path buildFolderPath = Paths .get (buildFolder );
262+ return buildFolderPath .toAbsolutePath ().toString ();
263+ }
264+ catch (CoreException e )
265+ {
266+ throw new IOException ("Failed to get build directory for project: " + projectName , e );
267+ }
266268 }
267269
268270 private static void thenClangdFileContentChecked () throws Exception
@@ -290,31 +292,32 @@ private static void thenClangFormatContentChecked() throws Exception
290292 bot .cTabItem (".clang-format" ).activate ();
291293 assertTrue (ProjectTestOperations .checkExactMatchInTextEditor (
292294 """
293- # We'll use defaults from the LLVM style, but with some modifications so that it's close to the CDT K&R style.
294- BasedOnStyle: LLVM
295- UseTab: Always
296- IndentWidth: 4
297- TabWidth: 4
298- BreakConstructorInitializers: AfterColon
299- IndentAccessModifiers: false
300- AccessModifierOffset: -4
301- """ ,
295+ # We'll use defaults from the LLVM style, but with some modifications so that it's close to the CDT K&R style.
296+ BasedOnStyle: LLVM
297+ UseTab: Always
298+ IndentWidth: 4
299+ TabWidth: 4
300+ BreakConstructorInitializers: AfterColon
301+ IndentAccessModifiers: false
302+ AccessModifierOffset: -4
303+ """ ,
302304 bot ));
303305 }
304306
305307 private static void thenClangFormatContentEdited () throws Exception
306308 {
307309 SWTBotEditor textEditor = bot .activeEditor ();
308- textEditor .toTextEditor ().setText ("""
309- # We'll use defaults from the LLVM style, but with some modifications so that it's close to the CDT K&R style.
310- BasedOnStyle: LLVM
311- UseTab: Always
312- IndentWidth: 0
313- TabWidth: 0
314- BreakConstructorInitializers: AfterColon
315- IndentAccessModifiers: false
316- AccessModifierOffset: -4
317- """ );
310+ textEditor .toTextEditor ().setText (
311+ """
312+ # We'll use defaults from the LLVM style, but with some modifications so that it's close to the CDT K&R style.
313+ BasedOnStyle: LLVM
314+ UseTab: Always
315+ IndentWidth: 0
316+ TabWidth: 0
317+ BreakConstructorInitializers: AfterColon
318+ IndentAccessModifiers: false
319+ AccessModifierOffset: -4
320+ """ );
318321 }
319322
320323 private static void addSpaceToMainFile () throws Exception
@@ -391,39 +394,43 @@ private static void thenMainFileShellClosed() throws IOException
391394 bot .shell ("Save Resource" ).bot ().button ("Save" ).click ();
392395 }
393396
394- private static String getExpectedBuildFolderPATHforClangdAdditionalArgument (String projectName ) throws IOException
397+ private static String getExpectedBuildFolderPATHforClangdAdditionalArgument (String projectName )
398+ throws IOException
395399 {
396- try {
397- IProject project = ResourcesPlugin .getWorkspace ().getRoot ().getProject (projectName );
398- String buildFolder = IDFUtil .getBuildDir (project );
399- Path buildFolderPath = Paths .get (buildFolder );
400- return "--compile-commands-dir=" + buildFolderPath .toAbsolutePath ().toString ();
401- } catch (CoreException e ) {
402- throw new IOException ("Failed to get build directory for project: " + projectName , e );
403- }
400+ try
401+ {
402+ IProject project = ResourcesPlugin .getWorkspace ().getRoot ().getProject (projectName );
403+ String buildFolder = IDFUtil .getBuildDir (project );
404+ Path buildFolderPath = Paths .get (buildFolder );
405+ return "--compile-commands-dir=" + buildFolderPath .toAbsolutePath ().toString ();
406+ }
407+ catch (CoreException e )
408+ {
409+ throw new IOException ("Failed to get build directory for project: " + projectName , e );
410+ }
404411 }
405412
406413 private static String getXtensaToolchainPathBasedOnTheTargetConfigured () throws IOException
407414 {
408- String toolchain = IDFUtil .getToolchainExePathForActiveTarget ();
415+ String toolchain = IDFUtil .getToolchainExePathForActiveTarget ();
409416 Path toolchainPath = Paths .get (toolchain );
410417 return toolchainPath .toAbsolutePath ().toString ();
411418 }
412419
413420 private static void thenCompareActualClangdArgumentWithExpected (String projectName ) throws IOException
414- {
415- SWTBotShell prefrencesShell = bot .shell ("Preferences" );
416- String actualClangdPath = prefrencesShell .bot ().textWithLabel ("Additional" ).getText ();
417- String expectedClangdPath = getExpectedBuildFolderPATHforClangdAdditionalArgument (projectName );
418- assertTrue (expectedClangdPath .equals (actualClangdPath ));
421+ {
422+ SWTBotShell prefrencesShell = bot .shell ("Preferences" );
423+ String actualClangdPath = prefrencesShell .bot ().textWithLabel ("Additional" ).getText ();
424+ String expectedClangdPath = getExpectedBuildFolderPATHforClangdAdditionalArgument (projectName );
425+ assertTrue (expectedClangdPath .equals (actualClangdPath ));
419426 }
420427
421428 private static void thenCompareActualClangdDriversWithExpected (String projectName ) throws IOException
422- {
423- SWTBotShell prefrencesShell = bot .shell ("Preferences" );
424- String actualClangdPath = prefrencesShell .bot ().textWithLabel ("Drivers" ).getText ();
425- String expectedClangdPath = getXtensaToolchainPathBasedOnTheTargetConfigured () ;
426- assertTrue ( expectedClangdPath . equals ( actualClangdPath ) );
429+ {
430+ SWTBotShell prefrencesShell = bot .shell ("Preferences" );
431+ String actualDriversPath = prefrencesShell .bot ().textWithLabel ("Drivers" ).getText ();
432+ String expectedDriversPath = "**" ;
433+ assertEquals ( expectedDriversPath , actualDriversPath );
427434 }
428435
429436 private static void whenProjectIsBuiltUsingContextMenu (String projectName ) throws IOException
@@ -444,17 +451,19 @@ private static void whenOpenClangdPreferences() throws Exception
444451 prefrencesShell .bot ().tree ().getTreeItem ("C/C++" ).getNode ("Editor (LSP)" ).getNode ("clangd" ).select ();
445452 }
446453
447- private static void closePreferencesDialog () {
448- SWTBotShell preferencesShell = bot .shell ("Preferences" );
449- preferencesShell .bot ().button ("Cancel" ).click (); // Or "Apply and Close"
450- TestWidgetWaitUtility .waitWhileDialogIsVisible (bot , "Preferences" , 10000 );
454+ private static void closePreferencesDialog ()
455+ {
456+ SWTBotShell preferencesShell = bot .shell ("Preferences" );
457+ preferencesShell .bot ().button ("Cancel" ).click (); // Or "Apply and Close"
458+ TestWidgetWaitUtility .waitWhileDialogIsVisible (bot , "Preferences" , 10000 );
451459 }
452460
453- private static void closeTargetDialog () {
461+ private static void closeTargetDialog ()
462+ {
454463 TestWidgetWaitUtility .waitForDialogToAppear (bot , "IDF Launch Target Changed" , 10000 );
455- SWTBotShell preferencesShell = bot .shell ("IDF Launch Target Changed" );
456- preferencesShell .bot ().button ("Yes" ).click (); // Or "Apply and Close"
457- TestWidgetWaitUtility .waitWhileDialogIsVisible (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 );
458467 }
459468
460469 private static void cleanTestEnv ()
0 commit comments