@@ -358,13 +358,21 @@ private boolean downloadOrLoadModel(ActivityScenario<MainActivity> scenario) thr
358358
359359 // If download button is available and enabled, click it
360360 if (downloadEnabled .get () && buttonText .get ().equals ("Download Model" )) {
361+ android .util .Log .i ("UIWorkflowTest" , "Clicking download button to download model" );
361362 onView (withId (R .id .downloadModelButton )).perform (click ());
362363
363- // Wait for download to complete (max 60 seconds)
364- boolean downloadComplete = waitForModelReady (scenario , 60000 );
364+ // Wait for download to complete (max 120 seconds for CI environment)
365+ android .util .Log .i ("UIWorkflowTest" , "Waiting for model download to complete..." );
366+ boolean downloadComplete = waitForModelReady (scenario , 120000 );
367+ if (downloadComplete ) {
368+ android .util .Log .i ("UIWorkflowTest" , "Model download completed successfully" );
369+ } else {
370+ android .util .Log .e ("UIWorkflowTest" , "Model download timed out after 120 seconds" );
371+ }
365372 return downloadComplete ;
366373 }
367374
375+ android .util .Log .w ("UIWorkflowTest" , "Download button not available or not enabled. Button text: " + buttonText .get ());
368376 return false ;
369377 }
370378
@@ -377,19 +385,37 @@ private boolean downloadOrLoadModel(ActivityScenario<MainActivity> scenario) thr
377385 */
378386 private boolean waitForModelReady (ActivityScenario <MainActivity > scenario , long timeoutMs ) throws InterruptedException {
379387 long startTime = System .currentTimeMillis ();
388+ int pollCount = 0 ;
380389 while (System .currentTimeMillis () - startTime < timeoutMs ) {
381390 AtomicBoolean modelReady = new AtomicBoolean (false );
391+ AtomicReference <String > downloadButtonText = new AtomicReference <>("" );
382392 scenario .onActivity (activity -> {
383393 // Model is ready when Run button is visible and enabled
384394 android .view .View runButton = activity .findViewById (R .id .xnnpackButton );
385395 modelReady .set (runButton .getVisibility () == android .view .View .VISIBLE && runButton .isEnabled ());
396+
397+ // Also check download button state for debugging
398+ android .widget .Button downloadButton = activity .findViewById (R .id .downloadModelButton );
399+ if (downloadButton != null ) {
400+ downloadButtonText .set (downloadButton .getText ().toString ());
401+ }
386402 });
387403
388404 if (modelReady .get ()) {
405+ android .util .Log .i ("UIWorkflowTest" , "Model ready after " + (System .currentTimeMillis () - startTime ) + "ms" );
389406 return true ;
390407 }
408+
409+ // Log progress every 10 seconds
410+ pollCount ++;
411+ if (pollCount % 10 == 0 ) {
412+ long elapsed = System .currentTimeMillis () - startTime ;
413+ android .util .Log .i ("UIWorkflowTest" , "Still waiting for model... elapsed: " + elapsed + "ms, download button: " + downloadButtonText .get ());
414+ }
415+
391416 Thread .sleep (1000 ); // Poll every second
392417 }
418+ android .util .Log .e ("UIWorkflowTest" , "Timeout waiting for model after " + timeoutMs + "ms" );
393419 return false ;
394420 }
395421
0 commit comments