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
910import java .io .IOException ;
1011
1112import org .eclipse .swtbot .eclipse .finder .SWTWorkbenchBot ;
1213import org .eclipse .swtbot .eclipse .finder .widgets .SWTBotView ;
1314import org .eclipse .swtbot .swt .finder .junit .SWTBotJunit4ClassRunner ;
15+ import org .eclipse .swtbot .swt .finder .waits .DefaultCondition ;
16+ import org .eclipse .swtbot .swt .finder .widgets .SWTBotText ;
1417import org .junit .AfterClass ;
1518import org .junit .BeforeClass ;
1619import org .junit .FixMethodOrder ;
@@ -159,27 +162,73 @@ private static void whenSDKconfigFileOpenedUsingContextMenu() throws IOException
159162 TestWidgetWaitUtility .waitForCTabToAppear (bot , "SDK Configuration (sdkconfig)" , 10000 );
160163 }
161164
162- private static void thenSDKconfigFileContentChecked () throws Exception
165+ private static void openPartitionTableSettings () throws Exception
163166 {
164167 bot .cTabItem ("SDK Configuration (sdkconfig)" ).activate ();
165168 TestWidgetWaitUtility .waitForTreeItem ("Partition Table" , bot .tree (1 ), bot );
166169 bot .tree (1 ).getTreeItem ("Partition Table" ).click ();
167170 bot .sleep (1000 );
168- assertTrue ("'Offset of partition table (hex)' does not match '0x8000'" ,
169- bot .textWithLabel ("Offset of partition table (hex)" ).getText ().matches ("0x8000" ));
171+ }
172+
173+ private static void setPartitionTableOffset (String hexValue )
174+ {
175+ SWTBotText offsetField = bot .textWithLabel ("Offset of partition table (hex)" );
176+ offsetField .setFocus ();
177+ offsetField .selectAll ();
178+ offsetField .setText (hexValue );
179+ bot .sleep (500 );
180+
181+ if (!offsetField .getText ().equalsIgnoreCase (hexValue ))
182+ {
183+ offsetField .setFocus ();
184+ offsetField .selectAll ();
185+ offsetField .typeText (hexValue );
186+ bot .sleep (500 );
187+ }
188+ }
189+
190+ private static void waitForPartitionTableOffset (String hexValue ) throws Exception
191+ {
192+ bot .waitUntil (new DefaultCondition ()
193+ {
194+ @ Override
195+ public boolean test () throws Exception
196+ {
197+ return bot .textWithLabel ("Offset of partition table (hex)" ).getText ()
198+ .equalsIgnoreCase (hexValue );
199+ }
200+
201+ @ Override
202+ public String getFailureMessage ()
203+ {
204+ return "Partition table offset did not become " + hexValue ;
205+ }
206+ }, 15000 , 500 );
207+ }
208+
209+ private static void assertPartitionTableOffset (String expectedHexValue )
210+ {
211+ String actual = bot .textWithLabel ("Offset of partition table (hex)" ).getText ();
212+ assertEquals ("'Offset of partition table (hex)' does not match '" + expectedHexValue + "'" ,
213+ expectedHexValue .toLowerCase (), actual .toLowerCase ());
214+ }
215+
216+ private static void thenSDKconfigFileContentChecked () throws Exception
217+ {
218+ openPartitionTableSettings ();
219+ waitForPartitionTableOffset ("0x8000" );
220+ assertPartitionTableOffset ("0x8000" );
170221 }
171222
172223 private static void thenSDKconfigFileContentEdited () throws Exception
173224 {
174- bot .cTabItem ("SDK Configuration (sdkconfig)" ).activate ();
175- TestWidgetWaitUtility .waitForTreeItem ("Partition Table" , bot .tree (1 ), bot );
176- bot .tree (1 ).getTreeItem ("Partition Table" ).click ();
177- bot .sleep (1000 );
178- bot .textWithLabel ("Offset of partition table (hex)" ).setText ("0x4000" );
179- bot .sleep (1000 );
225+ openPartitionTableSettings ();
226+ setPartitionTableOffset ("0x4000" );
227+ waitForPartitionTableOffset ("0x4000" );
180228 bot .comboBoxWithLabel ("Partition Table" ).setSelection ("Custom partition table CSV" );
181229 bot .sleep (1000 );
182230 bot .checkBox ("Generate an MD5 checksum for the partition table" ).click ();
231+ bot .sleep (500 );
183232 }
184233
185234 private static void thenSDKconfigShellClosed () throws IOException
@@ -193,16 +242,15 @@ private static void whenSDKconfigFileIsSaved() throws IOException
193242 bot .cTabItem ("*SDK Configuration (sdkconfig)" ).close ();
194243 TestWidgetWaitUtility .waitForDialogToAppear (bot , "Save Resource" , 10000 );
195244 bot .shell ("Save Resource" ).bot ().button ("Save" ).click ();
245+ TestWidgetWaitUtility .waitForOperationsInProgressToFinishSync (bot );
246+ bot .sleep (1000 );
196247 }
197248
198249 private static void thenCheckChangesAreSaved () throws Exception
199250 {
200- bot .cTabItem ("SDK Configuration (sdkconfig)" ).activate ();
201- TestWidgetWaitUtility .waitForTreeItem ("Partition Table" , bot .tree (1 ), bot );
202- bot .tree (1 ).getTreeItem ("Partition Table" ).click ();
203- bot .sleep (1000 );
204- assertTrue ("'Offset of partition table (hex)' does not match '0x4000'" ,
205- bot .textWithLabel ("Offset of partition table (hex)" ).getText ().matches ("0x4000" ));
251+ openPartitionTableSettings ();
252+ waitForPartitionTableOffset ("0x4000" );
253+ assertPartitionTableOffset ("0x4000" );
206254 bot .sleep (1000 );
207255 assertTrue ("'Partition Table' does not match 'Custom partition table CSV'" ,
208256 bot .comboBoxWithLabel ("Partition Table" ).selection ().equals ("Custom partition table CSV" ));
0 commit comments