[go: nahoru, domu]

Skip to content

Commit

Permalink
Integrate Latest @ 250588966
Browse files Browse the repository at this point in the history
Changes to all...
- Update all Unity testapps to use Task.ContinueWithOnMainThread()
Changes to analytics/testapp ...
- Fixed compile error in Analytics automated test.
Changes to database/testapp ...
- Disable Database Unity desktop test for GoOffline
Changes to dynamic_links/testapp ...
- Disable Unity automatically testing short link generation on desktop.
- Fix compiler error when using ContinueWithOnMainThread() in testapps
Changes to messaging/testapp ...
- Disable Tests in Messaging Unity Testapp on Desktop

CL: 250588966
  • Loading branch information
Ryan Meier committed Jun 6, 2019
1 parent c537ed9 commit 30f2a3f
Show file tree
Hide file tree
Showing 10 changed files with 88 additions and 69 deletions.
10 changes: 5 additions & 5 deletions analytics/testapp/Assets/Firebase/Sample/Analytics/UIHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
// limitations under the License.

namespace Firebase.Sample.Analytics {
using Firebase;
using Firebase.Analytics;
using Firebase.Extensions;
using System;
using System.Threading.Tasks;
using UnityEngine;

using Firebase;
using Firebase.Analytics;

// Handler for UI buttons on the scene. Also performs some
// necessary setup (initializing the firebase app, etc) on
// startup.
Expand All @@ -37,7 +37,7 @@ public class UIHandler : MonoBehaviour {
// the required dependencies to use Firebase, and if not,
// add them if possible.
public virtual void Start() {
FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task => {
FirebaseApp.CheckAndFixDependenciesAsync().ContinueWithOnMainThread(task => {
dependencyStatus = task.Result;
if (dependencyStatus == DependencyStatus.Available) {
InitializeFirebase();
Expand Down Expand Up @@ -122,7 +122,7 @@ public class UIHandler : MonoBehaviour {

// Get the current app instance ID.
public Task<string> DisplayAnalyticsInstanceId() {
return FirebaseAnalytics.GetAnalyticsInstanceIdAsync().ContinueWith(task => {
return FirebaseAnalytics.GetAnalyticsInstanceIdAsync().ContinueWithOnMainThread(task => {
if (task.IsCanceled) {
DebugLog("App instance ID fetch was canceled.");
} else if (task.IsFaulted) {
Expand Down
59 changes: 31 additions & 28 deletions auth/testapp/Assets/Firebase/Sample/Auth/UIHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#endif

namespace Firebase.Sample.Auth {
using Firebase.Extensions;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
Expand Down Expand Up @@ -70,7 +71,7 @@ public class UIHandler : MonoBehaviour {
// the required dependencies to use Firebase, and if not,
// add them if possible.
public virtual void Start() {
Firebase.FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task => {
Firebase.FirebaseApp.CheckAndFixDependenciesAsync().ContinueWithOnMainThread(task => {
dependencyStatus = task.Result;
if (dependencyStatus == Firebase.DependencyStatus.Available) {
InitializeFirebase();
Expand Down Expand Up @@ -232,7 +233,7 @@ public class UIHandler : MonoBehaviour {
void IdTokenChanged(object sender, System.EventArgs eventArgs) {
Firebase.Auth.FirebaseAuth senderAuth = sender as Firebase.Auth.FirebaseAuth;
if (senderAuth == auth && senderAuth.CurrentUser != null && !fetchingToken) {
senderAuth.CurrentUser.TokenAsync(false).ContinueWith(
senderAuth.CurrentUser.TokenAsync(false).ContinueWithOnMainThread(
task => DebugLog(String.Format("Token[0:8] = {0}", task.Result.Substring(0, 8))));
}
}
Expand Down Expand Up @@ -271,7 +272,7 @@ public class UIHandler : MonoBehaviour {
// reset by AuthStateChanged() when the new user is created and signed in.
string newDisplayName = displayName;
return auth.CreateUserWithEmailAndPasswordAsync(email, password)
.ContinueWith((task) => {
.ContinueWithOnMainThread((task) => {
EnableUI();
if (LogTaskCompletion(task, "User Creation")) {
var user = task.Result;
Expand All @@ -294,7 +295,7 @@ public class UIHandler : MonoBehaviour {
return auth.CurrentUser.UpdateUserProfileAsync(new Firebase.Auth.UserProfile {
DisplayName = displayName,
PhotoUrl = auth.CurrentUser.PhotoUrl,
}).ContinueWith(task => {
}).ContinueWithOnMainThread(task => {
EnableUI();
if (LogTaskCompletion(task, "User profile")) {
DisplayDetailedUserInfo(auth.CurrentUser, 1);
Expand All @@ -308,11 +309,11 @@ public class UIHandler : MonoBehaviour {
DisableUI();
if (signInAndFetchProfile) {
return auth.SignInAndRetrieveDataWithCredentialAsync(
Firebase.Auth.EmailAuthProvider.GetCredential(email, password)).ContinueWith(
Firebase.Auth.EmailAuthProvider.GetCredential(email, password)).ContinueWithOnMainThread(
HandleSignInWithSignInResult);
} else {
return auth.SignInWithEmailAndPasswordAsync(email, password)
.ContinueWith(HandleSignInWithUser);
.ContinueWithOnMainThread(HandleSignInWithUser);
}
}

Expand All @@ -324,11 +325,11 @@ public class UIHandler : MonoBehaviour {
DisableUI();
if (signInAndFetchProfile) {
return auth.SignInAndRetrieveDataWithCredentialAsync(
Firebase.Auth.EmailAuthProvider.GetCredential(email, password)).ContinueWith(
Firebase.Auth.EmailAuthProvider.GetCredential(email, password)).ContinueWithOnMainThread(
HandleSignInWithSignInResult);
} else {
return auth.SignInWithCredentialAsync(
Firebase.Auth.EmailAuthProvider.GetCredential(email, password)).ContinueWith(
Firebase.Auth.EmailAuthProvider.GetCredential(email, password)).ContinueWithOnMainThread(
HandleSignInWithUser);
}
}
Expand All @@ -337,7 +338,7 @@ public class UIHandler : MonoBehaviour {
public Task SigninAnonymouslyAsync() {
DebugLog("Attempting to sign anonymously...");
DisableUI();
return auth.SignInAnonymouslyAsync().ContinueWith(HandleSignInWithUser);
return auth.SignInAnonymouslyAsync().ContinueWithOnMainThread(HandleSignInWithUser);
}

public void AuthenticateToGameCenter() {
Expand All @@ -352,7 +353,7 @@ public class UIHandler : MonoBehaviour {

public Task SignInWithGameCenterAsync() {
var credentialTask = Firebase.Auth.GameCenterAuthProvider.GetCredentialAsync();
var continueTask = credentialTask.ContinueWith(task => {
var continueTask = credentialTask.ContinueWithOnMainThread(task => {
if(!task.IsCompleted)
return null;
Expand All @@ -362,7 +363,7 @@ public class UIHandler : MonoBehaviour {
var credential = task.Result;
var loginTask = auth.SignInWithCredentialAsync(credential);
return loginTask.ContinueWith(HandleSignInWithUser);
return loginTask.ContinueWithOnMainThread(HandleSignInWithUser);
});

return continueTask;
Expand Down Expand Up @@ -396,14 +397,16 @@ public class UIHandler : MonoBehaviour {
Firebase.Auth.Credential cred =
Firebase.Auth.EmailAuthProvider.GetCredential(email, password);
if (signInAndFetchProfile) {
return auth.CurrentUser.LinkAndRetrieveDataWithCredentialAsync(cred).ContinueWith(
task => {
if (LogTaskCompletion(task, "Link Credential")) {
return
auth.CurrentUser.LinkAndRetrieveDataWithCredentialAsync(cred).ContinueWithOnMainThread(
task => {
if (LogTaskCompletion(task, "Link Credential")) {
DisplaySignInResult(task.Result, 1);
}
}
});
);
} else {
return auth.CurrentUser.LinkWithCredentialAsync(cred).ContinueWith(task => {
return auth.CurrentUser.LinkWithCredentialAsync(cred).ContinueWithOnMainThread(task => {
if (LogTaskCompletion(task, "Link Credential")) {
DisplayDetailedUserInfo(task.Result, 1);
}
Expand All @@ -424,14 +427,14 @@ public class UIHandler : MonoBehaviour {
DisableUI();
Firebase.Auth.Credential cred = Firebase.Auth.EmailAuthProvider.GetCredential(email, password);
if (signInAndFetchProfile) {
return user.ReauthenticateAndRetrieveDataAsync(cred).ContinueWith(task => {
return user.ReauthenticateAndRetrieveDataAsync(cred).ContinueWithOnMainThread(task => {
EnableUI();
if (LogTaskCompletion(task, "Reauthentication")) {
DisplaySignInResult(task.Result, 1);
}
});
} else {
return user.ReauthenticateAsync(cred).ContinueWith(task => {
return user.ReauthenticateAsync(cred).ContinueWithOnMainThread(task => {
EnableUI();
if (LogTaskCompletion(task, "Reauthentication")) {
DisplayDetailedUserInfo(auth.CurrentUser, 1);
Expand All @@ -447,7 +450,7 @@ public class UIHandler : MonoBehaviour {
return;
}
DebugLog("Reload User Data");
auth.CurrentUser.ReloadAsync().ContinueWith(task => {
auth.CurrentUser.ReloadAsync().ContinueWithOnMainThread(task => {
if (LogTaskCompletion(task, "Reload")) {
DisplayDetailedUserInfo(auth.CurrentUser, 1);
}
Expand All @@ -462,7 +465,7 @@ public class UIHandler : MonoBehaviour {
}
DebugLog("Fetching user token");
fetchingToken = true;
auth.CurrentUser.TokenAsync(false).ContinueWith(task => {
auth.CurrentUser.TokenAsync(false).ContinueWithOnMainThread(task => {
fetchingToken = false;
if (LogTaskCompletion(task, "User token fetch")) {
DebugLog("Token = " + task.Result);
Expand Down Expand Up @@ -492,7 +495,7 @@ public class UIHandler : MonoBehaviour {
DisableUI();
return auth.CurrentUser.UnlinkAsync(
Firebase.Auth.EmailAuthProvider.GetCredential(email, password).Provider)
.ContinueWith(task => {
.ContinueWithOnMainThread(task => {
EnableUI();
LogTaskCompletion(task, "Unlinking");
});
Expand All @@ -509,7 +512,7 @@ public class UIHandler : MonoBehaviour {
if (auth.CurrentUser != null) {
DebugLog(String.Format("Attempting to delete user {0}...", auth.CurrentUser.UserId));
DisableUI();
return auth.CurrentUser.DeleteAsync().ContinueWith(task => {
return auth.CurrentUser.DeleteAsync().ContinueWithOnMainThread(task => {
EnableUI();
LogTaskCompletion(task, "Delete user");
});
Expand All @@ -522,7 +525,7 @@ public class UIHandler : MonoBehaviour {

// Show the providers for the current email address.
protected void DisplayProvidersForEmail() {
auth.FetchProvidersForEmailAsync(email).ContinueWith((authTask) => {
auth.FetchProvidersForEmailAsync(email).ContinueWithOnMainThread((authTask) => {
if (LogTaskCompletion(authTask, "Fetch Providers")) {
DebugLog(String.Format("Email Providers for '{0}':", email));
foreach (string provider in authTask.Result) {
Expand All @@ -534,7 +537,7 @@ public class UIHandler : MonoBehaviour {

// Send a password reset email to the current email address.
protected void SendPasswordResetEmail() {
auth.SendPasswordResetEmailAsync(email).ContinueWith((authTask) => {
auth.SendPasswordResetEmailAsync(email).ContinueWithOnMainThread((authTask) => {
if (LogTaskCompletion(authTask, "Send Password Reset Email")) {
DebugLog("Password reset email sent to " + email);
}
Expand All @@ -548,10 +551,10 @@ public class UIHandler : MonoBehaviour {
verificationCompleted: (cred) => {
DebugLog("Phone Auth, auto-verification completed");
if (signInAndFetchProfile) {
auth.SignInAndRetrieveDataWithCredentialAsync(cred).ContinueWith(
auth.SignInAndRetrieveDataWithCredentialAsync(cred).ContinueWithOnMainThread(
HandleSignInWithSignInResult);
} else {
auth.SignInWithCredentialAsync(cred).ContinueWith(HandleSignInWithUser);
auth.SignInWithCredentialAsync(cred).ContinueWithOnMainThread(HandleSignInWithUser);
}
},
verificationFailed: (error) => {
Expand All @@ -572,10 +575,10 @@ public class UIHandler : MonoBehaviour {
// receivedCode should have been input by the user.
var cred = phoneAuthProvider.GetCredential(phoneAuthVerificationId, receivedCode);
if (signInAndFetchProfile) {
auth.SignInAndRetrieveDataWithCredentialAsync(cred).ContinueWith(
auth.SignInAndRetrieveDataWithCredentialAsync(cred).ContinueWithOnMainThread(
HandleSignInWithSignInResult);
} else {
auth.SignInWithCredentialAsync(cred).ContinueWith(HandleSignInWithUser);
auth.SignInWithCredentialAsync(cred).ContinueWithOnMainThread(HandleSignInWithUser);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
// limitations under the License.

namespace Firebase.Sample.Crashlytics {
using System;
using UnityEngine;

using Firebase;
using Firebase.Crashlytics;
using Firebase.Extensions;
using System;
using UnityEngine;

// Handler for UI buttons on the scene. Also performs some
// necessary setup (initializing the firebase app, etc) on
Expand All @@ -36,7 +36,7 @@ public class UIHandler : MonoBehaviour {
// the required dependencies to use Firebase, and if not,
// add them if possible.
public virtual void Start() {
FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task => {
FirebaseApp.CheckAndFixDependenciesAsync().ContinueWithOnMainThread(task => {
dependencyStatus = task.Result;
if (dependencyStatus == DependencyStatus.Available) {
InitializeFirebase();
Expand Down
7 changes: 4 additions & 3 deletions database/testapp/Assets/Firebase/Sample/Database/UIHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
namespace Firebase.Sample.Database {
using Firebase;
using Firebase.Database;
using Firebase.Extensions;
using Firebase.Unity.Editor;
using System;
using System.Collections;
Expand Down Expand Up @@ -50,7 +51,7 @@ public class UIHandler : MonoBehaviour {
leaderBoard.Clear();
leaderBoard.Add("Firebase Top " + MaxScores.ToString() + " Scores");

FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task => {
FirebaseApp.CheckAndFixDependenciesAsync().ContinueWithOnMainThread(task => {
dependencyStatus = task.Result;
if (dependencyStatus == DependencyStatus.Available) {
InitializeFirebase();
Expand Down Expand Up @@ -178,7 +179,7 @@ public class UIHandler : MonoBehaviour {
// Use a transaction to ensure that we do not encounter issues with
// simultaneous updates that otherwise might create more than MaxScores top scores.
reference.RunTransaction(AddScoreTransaction)
.ContinueWith(task => {
.ContinueWithOnMainThread(task => {
if (task.Exception != null) {
DebugLog(task.Exception.ToString());
} else if (task.IsCompleted) {
Expand Down Expand Up @@ -283,4 +284,4 @@ public class UIHandler : MonoBehaviour {
GUILayout.EndArea();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
// limitations under the License.

namespace Firebase.Sample.DynamicLinks {
using Firebase;
using Firebase.DynamicLinks;
using Firebase.Extensions;
using System;
using System.Collections;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.UI;

using Firebase;
using Firebase.DynamicLinks;

// Handler for UI buttons on the scene. Also performs some
// necessary setup (initializing the firebase app, etc) on
// startup.
Expand Down Expand Up @@ -52,7 +52,7 @@ public class UIHandler : MonoBehaviour {
// the required dependencies to use Firebase, and if not,
// add them if possible.
public virtual void Start() {
FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task => {
FirebaseApp.CheckAndFixDependenciesAsync().ContinueWithOnMainThread(task => {
dependencyStatus = task.Result;
if (dependencyStatus == DependencyStatus.Available) {
InitializeFirebase();
Expand Down Expand Up @@ -185,7 +185,7 @@ public class UIHandler : MonoBehaviour {

var components = CreateDynamicLinkComponents();
return DynamicLinks.GetShortLinkAsync(components, options)
.ContinueWith<ShortDynamicLink>((task) => {
.ContinueWithOnMainThread((task) => {
if (task.IsCanceled) {
DebugLog("Short link creation canceled");
} else if (task.IsFaulted) {
Expand Down Expand Up @@ -258,4 +258,4 @@ public class UIHandler : MonoBehaviour {
GUILayout.EndArea();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@
// limitations under the License.

namespace Firebase.Sample.Functions {
using System;
using System.Threading.Tasks;
using Firebase;
using Firebase.Extensions;
using Firebase.Functions;
using System;
using System.Threading.Tasks;

public class TestCase {
// The name of the HTTPS callable function to call.
Expand All @@ -43,7 +44,7 @@ public class TestCase {
public Task RunAsync(FirebaseFunctions functions,
Utils.Reporter reporter) {
var func = functions.GetHttpsCallable(Name);
return func.CallAsync(Input).ContinueWith((task) => {
return func.CallAsync(Input).ContinueWithOnMainThread((task) => {
if (ExpectedError == FunctionsErrorCode.None) {
// We expected no error.
if (task.IsFaulted) {
Expand Down Expand Up @@ -81,4 +82,4 @@ public class TestCase {
});
}
}
}
}
Loading

0 comments on commit 30f2a3f

Please sign in to comment.