diff options
author | Gil <mcg@google.com> | 2018-02-22 08:26:22 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-22 08:26:22 -0800 |
commit | 4dc63f8d7cbf60417b88c6a77839ea32656627b9 (patch) | |
tree | 9e06e7c40b71caea3a89813a506c9aebccdf1401 /Firestore/core/src/firebase/firestore/auth/user.h | |
parent | 935f3ca7d749f96c7207236a39c57f32a02c05d3 (diff) |
Fix Firestore tests for M22 (#834)
* Add FIRFirestoreTests to the Firestore Xcode project
* Avoid waitForExpectations:timeout:
This API was added in Xcode 8.3, but we still build production releases
with Xcode 8.2. waitForExpectationsWithTimeout:handler: is available
from Xcode 7.2.
* Add AppForUnitTesting
Add a utility for constructing a Firebase App for testing.
* Handle the nil UID from FIRAuth
* Avoid running CMake tests twice
* Only build app_testing on Apple platforms
* Revise test.sh messages
Diffstat (limited to 'Firestore/core/src/firebase/firestore/auth/user.h')
-rw-r--r-- | Firestore/core/src/firebase/firestore/auth/user.h | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/Firestore/core/src/firebase/firestore/auth/user.h b/Firestore/core/src/firebase/firestore/auth/user.h index cc7b66d..3918c61 100644 --- a/Firestore/core/src/firebase/firestore/auth/user.h +++ b/Firestore/core/src/firebase/firestore/auth/user.h @@ -43,12 +43,6 @@ class User { /** Construct an authenticated user with the given UID. */ explicit User(const absl::string_view uid); -#if defined(__OBJC__) - explicit User(NSString* uid) - : User(firebase::firestore::util::MakeStringView(uid)) { - } -#endif // defined(__OBJC__) - const std::string& uid() const { return uid_; } @@ -62,6 +56,20 @@ class User { /** Returns an unauthenticated instance. */ static const User& Unauthenticated(); +#if defined(__OBJC__) + /** + * Returns an authenticated user if uid is non-nil, otherwise an + * unauthenticated user. + */ + static User FromUid(NSString* _Nullable uid) { + if (uid == nil) { + return Unauthenticated(); + } else { + return User(util::MakeStringView(uid)); + } + } +#endif // defined(__OBJC__) + User& operator=(const User& other) = default; friend bool operator==(const User& lhs, const User& rhs); |