@@ -93,7 +93,38 @@ public IEnumerator TestOpenCloseRotatingOrbsPrefab()
9393 yield return null ;
9494 }
9595
96- private async Task TestOpenCloseProgressIndicatorAsync ( GameObject progressIndicatorObject , IProgressIndicator progressIndicator , float timeOpen = 2f )
96+ /// <summary>
97+ /// Tests that prefab finishes closing after being disabled at runtime.
98+ /// </summary>
99+ [ UnityTest ]
100+ public IEnumerator TestHideBeforeClosingRotatingOrbsPrefab ( )
101+ {
102+ GameObject progressIndicatorObject ;
103+ IProgressIndicator progressIndicator ;
104+ InstantiatePrefab ( progressIndicatorRotatingOrbsPrefabPath , out progressIndicatorObject , out progressIndicator ) ;
105+ Task testTask = TestOpenCloseProgressIndicatorAsync ( progressIndicatorObject , progressIndicator , 3f , hideAfterOpening : true ) ;
106+
107+ // Wait a maximum time before considering the progress bar as stuck
108+ float timeStarted = Time . time ;
109+ const float timeout = 5.0f ;
110+ while ( ! testTask . IsCompleted )
111+ {
112+ if ( Time . time < timeStarted + timeout )
113+ {
114+ yield return null ;
115+ }
116+ else
117+ {
118+ Assert . Fail ( "The progress bar is stuck closing." ) ;
119+ }
120+ }
121+
122+ // clean up
123+ GameObject . Destroy ( progressIndicatorObject ) ;
124+ yield return null ;
125+ }
126+
127+ private async Task TestOpenCloseProgressIndicatorAsync ( GameObject progressIndicatorObject , IProgressIndicator progressIndicator , float timeOpen = 2f , bool hideAfterOpening = false )
97128 {
98129 // Deactivate the progress indicator
99130 progressIndicatorObject . SetActive ( false ) ;
@@ -111,6 +142,12 @@ private async Task TestOpenCloseProgressIndicatorAsync(GameObject progressIndica
111142 // Make sure it's actually open
112143 Assert . True ( progressIndicator . State == ProgressIndicatorState . Open , "Progress indicator was not open after open async call: " + progressIndicator . State ) ;
113144
145+ // Hide the gameObject if requested
146+ if ( hideAfterOpening )
147+ {
148+ progressIndicatorObject . SetActive ( false ) ;
149+ }
150+
114151 // Make sure we can set its progress and message while open
115152 // Also make sure we can set progress to a value greater than 1 without blowing anything up
116153 float timeStarted = Time . time ;
0 commit comments