@@ -93,7 +93,38 @@ public IEnumerator TestOpenCloseRotatingOrbsPrefab()
93
93
yield return null ;
94
94
}
95
95
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 )
97
128
{
98
129
// Deactivate the progress indicator
99
130
progressIndicatorObject . SetActive ( false ) ;
@@ -111,6 +142,12 @@ private async Task TestOpenCloseProgressIndicatorAsync(GameObject progressIndica
111
142
// Make sure it's actually open
112
143
Assert . True ( progressIndicator . State == ProgressIndicatorState . Open , "Progress indicator was not open after open async call: " + progressIndicator . State ) ;
113
144
145
+ // Hide the gameObject if requested
146
+ if ( hideAfterOpening )
147
+ {
148
+ progressIndicatorObject . SetActive ( false ) ;
149
+ }
150
+
114
151
// Make sure we can set its progress and message while open
115
152
// Also make sure we can set progress to a value greater than 1 without blowing anything up
116
153
float timeStarted = Time . time ;
0 commit comments