|
10 | 10 |
|
11 | 11 | import org.eclipse.swt.widgets.MenuItem; |
12 | 12 | import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; |
| 13 | +import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor; |
13 | 14 | import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView; |
14 | 15 | import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException; |
15 | 16 | import org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory; |
@@ -60,7 +61,16 @@ public static void waitForProjectBuild(SWTWorkbenchBot bot) throws IOException |
60 | 61 | consoleView.show(); |
61 | 62 | consoleView.setFocus(); |
62 | 63 | TestWidgetWaitUtility.waitUntilViewContains(bot, "Build complete", consoleView, |
63 | | - DefaultPropertyFetcher.getLongPropertyValue(DEFAULT_PROJECT_BUILD_WAIT_PROPERTY, 60000)); |
| 64 | + DefaultPropertyFetcher.getLongPropertyValue(DEFAULT_PROJECT_BUILD_WAIT_PROPERTY, 600000)); |
| 65 | + } |
| 66 | + |
| 67 | + public static void waitForProjectNewComponentInstalled(SWTWorkbenchBot bot) throws IOException |
| 68 | + { |
| 69 | + SWTBotView consoleView = viewConsole("ESP-IDF Console", bot); |
| 70 | + consoleView.show(); |
| 71 | + consoleView.setFocus(); |
| 72 | + TestWidgetWaitUtility.waitUntilViewContains(bot, "Successfully added dependency", consoleView, |
| 73 | + DefaultPropertyFetcher.getLongPropertyValue("Install New Component", 10000)); |
64 | 74 | } |
65 | 75 |
|
66 | 76 | public static SWTBotView viewConsole(String consoleType, SWTWorkbenchBot bot) |
@@ -89,6 +99,78 @@ public static void createDebugConfiguration(String projectName, SWTWorkbenchBot |
89 | 99 | } |
90 | 100 |
|
91 | 101 | } |
| 102 | + |
| 103 | + public static void refreshProjectUsingContextMenu(String projectName, SWTWorkbenchBot bot) |
| 104 | + { |
| 105 | + SWTBotTreeItem projectItem = fetchProjectFromProjectExplorer(projectName, bot); |
| 106 | + if (projectItem != null) |
| 107 | + { |
| 108 | + projectItem.select(); |
| 109 | + projectItem.contextMenu("Refresh").click(); |
| 110 | + } |
| 111 | + } |
| 112 | + |
| 113 | + public static void openProjectComponentYMLFileInTextEditorUsingContextMenu(String projectName, SWTWorkbenchBot bot) |
| 114 | + { |
| 115 | + SWTBotTreeItem projectItem = fetchProjectFromProjectExplorer(projectName, bot); |
| 116 | + if (projectItem != null) { |
| 117 | + projectItem.select(); |
| 118 | + projectItem.expand(); |
| 119 | + projectItem.getNode("main").expand(); |
| 120 | + |
| 121 | + int maxAttempts = 2; |
| 122 | + for (int attempt = 0; attempt <= maxAttempts; attempt++) { |
| 123 | + SWTBotTreeItem fileToOpenItem = findTreeItem(projectItem.getNode("main"), "idf_component.yml"); |
| 124 | + |
| 125 | + if (fileToOpenItem != null) { |
| 126 | + fileToOpenItem.select(); |
| 127 | + fileToOpenItem.doubleClick(); |
| 128 | + return; |
| 129 | + } |
| 130 | + |
| 131 | + else { |
| 132 | + try { |
| 133 | + Thread.sleep(3000); |
| 134 | + } catch (InterruptedException e) { |
| 135 | + e.printStackTrace(); |
| 136 | + } |
| 137 | + } |
| 138 | + } |
| 139 | + throw new RuntimeException("The 'idf_component.yml' file was not found in the 'main' subfolder."); |
| 140 | + } |
| 141 | + } |
| 142 | + |
| 143 | + private static SWTBotTreeItem findTreeItem(SWTBotTreeItem parent, String itemName) { |
| 144 | + for (SWTBotTreeItem child : parent.getItems()) { |
| 145 | + if (child.getText().equals(itemName)) { |
| 146 | + return child; |
| 147 | + } |
| 148 | + SWTBotTreeItem found = findTreeItem(child, itemName); |
| 149 | + if (found != null) { |
| 150 | + return found; |
| 151 | + } |
| 152 | + } |
| 153 | + return null; |
| 154 | + } |
| 155 | + |
| 156 | + public static void checkTextEditorContentForPhrase(String phrase, SWTWorkbenchBot bot) { |
| 157 | + SWTBotEditor textEditor = bot.activeEditor(); |
| 158 | + String editorText = textEditor.toTextEditor().getText(); |
| 159 | + |
| 160 | + if (!editorText.contains(phrase)) { |
| 161 | + throw new RuntimeException("The specified phrase '" + phrase + "' was not found in the text editor."); |
| 162 | + } |
| 163 | + } |
| 164 | + |
| 165 | + public static void openProjectNewComponentUsingContextMenu(String projectName, SWTWorkbenchBot bot) |
| 166 | + { |
| 167 | + SWTBotTreeItem projectItem = fetchProjectFromProjectExplorer(projectName, bot); |
| 168 | + if (projectItem != null) |
| 169 | + { |
| 170 | + projectItem.select(); |
| 171 | + projectItem.contextMenu("ESP-IDF: Install New Component").click(); |
| 172 | + } |
| 173 | + } |
92 | 174 |
|
93 | 175 | /** |
94 | 176 | * Creates an espressif idf project from the template |
|
0 commit comments