Skip to content

Commit 1df633b

Browse files
authored
Disable Session Id test on Android (#649)
* Disable SessionId test on Android * Update UIHandlerAutomated.cs * Update UIHandlerAutomated.cs * Update UIHandlerAutomated.cs
1 parent 2122d87 commit 1df633b

File tree

1 file changed

+23
-13
lines changed

1 file changed

+23
-13
lines changed

analytics/testapp/Assets/Firebase/Sample/Analytics/UIHandlerAutomated.cs

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public override void Start() {
3131
TestAnalyticsGroupJoinDoesNotThrow,
3232
TestAnalyticsLevelUpDoesNotThrow,
3333
TestGetSessionId,
34-
TestAnalyticsSetConsentDoesNotThrow,
34+
TestAnalyticsSetConsentDoesNotThrow,
3535
TestInstanceIdChangeAfterReset,
3636
TestResetAnalyticsData,
3737
// Temporarily disabled until this test is deflaked. b/143603151
@@ -201,18 +201,28 @@ Task TestGetSessionId() {
201201
// running this test.
202202
var tcs = new TaskCompletionSource<bool>();
203203
Task.Delay(TimeSpan.FromSeconds(5)).ContinueWithOnMainThread(task_ => {
204-
base.DisplaySessionId().ContinueWithOnMainThread(task => {
205-
if (task.IsCanceled) {
206-
tcs.TrySetException(new Exception("Unexpectedly canceled"));
207-
} else if (task.IsFaulted) {
208-
tcs.TrySetException(task.Exception);
209-
} else if (task.Result == 0) {
210-
tcs.TrySetException(new Exception("Zero ID returned"));
211-
} else {
212-
tcs.TrySetResult(true);
213-
}
214-
});
215-
});
204+
base.DisplaySessionId().ContinueWithOnMainThread(task => {
205+
if (task.IsCanceled) {
206+
tcs.TrySetException(new Exception("Unexpectedly canceled"));
207+
} else if (task.IsFaulted) {
208+
// Session ID has problems when running on the Android test infrastructure,
209+
// as it depends on play services, which is not guaranteed to be updated.
210+
// There is better logic to check this in the C++ tests, which we will just
211+
// rely on to test the general logic.
212+
if (Application.platform == RuntimePlatform.Android) {
213+
DebugLog("GetSessionId got an exception, but that might be expected on Android");
214+
DebugLog("Exception: " + task.Exception);
215+
tcs.TrySetResult(true);
216+
return;
217+
}
218+
tcs.TrySetException(task.Exception);
219+
} else if (task.Result == 0) {
220+
tcs.TrySetException(new Exception("Zero ID returned"));
221+
} else {
222+
tcs.TrySetResult(true);
223+
}
224+
});
225+
});
216226
return tcs.Task;
217227
}
218228

0 commit comments

Comments
 (0)