forked from firebase/quickstart-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommon_main.cc
More file actions
660 lines (594 loc) · 25.3 KB
/
common_main.cc
File metadata and controls
660 lines (594 loc) · 25.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
// Copyright 2016 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include <unistd.h>
#include <ctime>
#include <sstream>
#include <string>
#include "firebase/app.h"
#include "firebase/auth.h"
#if defined(__ANDROID__)
#include "google_play_services/availability.h"
#endif // defined(__ANDROID__)
// Thin OS abstraction layer.
#include "main.h" // NOLINT
using ::firebase::App;
using ::firebase::AppOptions;
using ::firebase::Future;
using ::firebase::FutureBase;
using ::firebase::auth::Auth;
using ::firebase::auth::Credential;
using ::firebase::auth::AuthError;
using ::firebase::auth::kAuthErrorNone;
using ::firebase::auth::kAuthErrorFailure;
using ::firebase::auth::kAuthErrorUnimplemented;
using ::firebase::auth::EmailAuthProvider;
using ::firebase::auth::FacebookAuthProvider;
using ::firebase::auth::GitHubAuthProvider;
using ::firebase::auth::GoogleAuthProvider;
using ::firebase::auth::TwitterAuthProvider;
using ::firebase::auth::User;
using ::firebase::auth::UserInfoInterface;
// Set this to true, and set the email/password, to test a custom email address.
static const bool kTestCustomEmail = false;
static const char kCustomEmail[] = "custom.email@example.com";
static const char kCustomPassword[] = "CustomPasswordGoesHere";
// Constants used during tests.
static const char kTestPassword[] = "testEmailPassword123";
static const char kTestEmailBad[] = "bad.test.email@example.com";
static const char kTestPasswordBad[] = "badTestPassword";
static const char kTestIdTokenBad[] = "bad id token for testing";
static const char kTestAccessTokenBad[] = "bad access token for testing";
static const char kTestPasswordUpdated[] = "testpasswordupdated";
static const char kFirebaseProviderId[] =
#if defined(__ANDROID__)
"firebase";
#else // !defined(__ANDROID__)
"Firebase";
#endif // !defined(__ANDROID__)
// Don't return until `future` is complete.
// Print a message for whether the result mathes our expectations.
// Returns true if the application should exit.
static bool WaitForFuture(FutureBase future, const char* fn,
AuthError expected_error) {
// Note if the future has not be started properly.
if (future.Status() == ::firebase::kFutureStatusInvalid) {
LogMessage("ERROR! Future for %s is invalid", fn);
return false;
}
// Wait for future to complete.
LogMessage(" Calling %s...", fn);
while (future.Status() == ::firebase::kFutureStatusPending) {
if (ProcessEvents(100)) return true;
}
// Log error result.
const AuthError error = static_cast<AuthError>(future.Error());
if (error == expected_error) {
const char* error_message = future.ErrorMessage();
if (error_message) {
LogMessage("%s completed as expected", fn);
} else {
LogMessage("%s completed as expected, error: %d '%s'", fn, error,
error_message);
}
} else {
LogMessage("ERROR! %s completed with error: %d, `%s`", fn, error,
future.ErrorMessage());
}
return false;
}
static bool WaitForSignInFuture(Future<User*> sign_in_future, const char* fn,
AuthError expected_error, Auth* auth) {
if (WaitForFuture(sign_in_future, fn, expected_error)) return true;
const User* const* sign_in_user_ptr = sign_in_future.Result();
const User* sign_in_user =
sign_in_user_ptr == nullptr ? nullptr : *sign_in_user_ptr;
const User* auth_user = auth->CurrentUser();
if (sign_in_user != auth_user) {
LogMessage("ERROR: future's user (%x) and CurrentUser (%x) don't match",
static_cast<int>(reinterpret_cast<intptr_t>(sign_in_user)),
static_cast<int>(reinterpret_cast<intptr_t>(auth_user)));
}
const bool should_be_null = expected_error != kAuthErrorNone;
const bool is_null = sign_in_user == nullptr;
if (should_be_null != is_null) {
LogMessage("ERROR: user pointer (%x) is incorrect",
static_cast<int>(reinterpret_cast<intptr_t>(auth_user)));
}
return false;
}
// Create an email that will be different from previous runs.
// Useful for testing creating new accounts.
static std::string CreateNewEmail() {
std::stringstream email;
email << "random_" << std::time(0) << "@gmail.com";
return email.str();
}
static void ExpectFalse(const char* test, bool value) {
if (value) {
LogMessage("ERROR! %s is true instead of false", test);
} else {
LogMessage("%s is false, as expected", test);
}
}
static void ExpectTrue(const char* test, bool value) {
if (value) {
LogMessage("%s is true, as expected", test);
} else {
LogMessage("ERROR! %s is false instead of true", test);
}
}
// Log results of a string comparison for `test`.
static void ExpectStringsEqual(const char* test, const char* expected,
const char* actual) {
if (strcmp(expected, actual) == 0) {
LogMessage("%s is '%s' as expected", test, actual);
} else {
LogMessage("ERROR! %s is '%s' instead of '%s'", test, actual, expected);
}
}
// Utility class for holding a user's login credentials.
class UserLogin {
public:
UserLogin(Auth* auth, const std::string& email, const std::string& password)
: auth_(auth), email_(email), password_(password), user_(nullptr) {}
explicit UserLogin(Auth* auth) : auth_(auth) {
email_ = CreateNewEmail();
password_ = kTestPassword;
}
~UserLogin() {
if (user_ != nullptr) {
Delete();
}
}
void Register() {
Future<User*> register_test_account =
auth_->CreateUserWithEmailAndPassword(email(), password());
WaitForSignInFuture(register_test_account,
"CreateUserWithEmailAndPassword() to create temp user",
kAuthErrorNone, auth_);
user_ = register_test_account.Result() ? *register_test_account.Result()
: nullptr;
}
void Login() {
Credential email_cred =
EmailAuthProvider::GetCredential(email(), password());
Future<User*> sign_in_cred = auth_->SignInWithCredential(email_cred);
WaitForSignInFuture(sign_in_cred,
"Auth::SignInWithCredential() pre-delete signin",
kAuthErrorNone, auth_);
}
void Delete() {
if (user_ != nullptr) {
Future<void> delete_future = user_->Delete();
if (delete_future.Status() == ::firebase::kFutureStatusInvalid) {
Login();
delete_future = user_->Delete();
}
WaitForFuture(delete_future, "User::Delete()", kAuthErrorNone);
}
user_ = nullptr;
}
const char* email() const { return email_.c_str(); }
const char* password() const { return password_.c_str(); }
User* user() const { return user_; }
void set_email(const char* email) { email_ = email; }
void set_password(const char* password) { password_ = password; }
private:
Auth* auth_;
std::string email_;
std::string password_;
User* user_;
};
// Execute all methods of the C++ Auth API.
extern "C" int common_main(int argc, const char* argv[]) {
App* app;
LogMessage("Starting Auth tests.");
// Create the App wrapper.
#if defined(__ANDROID__)
app = App::Create(AppOptions(), GetJniEnv(), GetActivity());
#else
app = App::Create(AppOptions());
#endif // defined(__ANDROID__)
LogMessage("Created the Firebase app %x.",
static_cast<int>(reinterpret_cast<intptr_t>(app)));
// Create the Auth class for that App.
::firebase::InitResult init_result;
bool try_again;
Auth* auth;
do {
try_again = false;
auth = Auth::GetAuth(app, &init_result);
#if defined(__ANDROID__)
// On Android, we need to update or activate Google Play services
// before we can initialize this Firebase module.
if (init_result == firebase::kInitResultFailedMissingDependency) {
LogMessage("Google Play services unavailable, trying to fix.");
firebase::Future<void> make_available =
google_play_services::MakeAvailable(app->GetJNIEnv(),
app->activity());
while (make_available.Status() != ::firebase::kFutureStatusComplete) {
if (ProcessEvents(100)) return 1; // Return if exit was triggered.
}
if (make_available.Error() == 0) {
LogMessage("Google Play services now available, continuing.");
try_again = true;
} else {
LogMessage("Google Play services still unavailable.");
}
}
#endif // defined(__ANDROID__)
} while (try_again);
if (init_result != firebase::kInitResultSuccess) {
LogMessage("Failed to initialize Auth, exiting.");
ProcessEvents(2000);
return 1;
}
LogMessage("Created the Auth %x class for the Firebase app.",
static_cast<int>(reinterpret_cast<intptr_t>(auth)));
// Test that CurrentUser() returns NULL right after creation.
if (auth->CurrentUser() != nullptr) {
LogMessage("ERROR: CurrentUser() returning %x instead of NULL",
auth->CurrentUser());
}
// --- Custom Profile tests --------------------------------------------------
{
if (kTestCustomEmail) {
// Test Auth::SignInWithEmailAndPassword().
// Sign in with email and password that have already been registered.
Future<User*> sign_in_future =
auth->SignInWithEmailAndPassword(kCustomEmail, kCustomPassword);
WaitForSignInFuture(sign_in_future,
"Auth::SignInWithEmailAndPassword() existing "
"(custom) email and password",
kAuthErrorNone, auth);
// Test SignOut() after signed in with email and password.
if (sign_in_future.Status() == ::firebase::kFutureStatusComplete) {
auth->SignOut();
if (auth->CurrentUser() != nullptr) {
LogMessage(
"ERROR: CurrentUser() returning %x instead of NULL after "
"SignOut()",
auth->CurrentUser());
}
}
}
}
// --- Auth tests ------------------------------------------------------------
{
UserLogin user_login(auth); // Generate a random name/password
user_login.Register();
if (!user_login.user()) {
LogMessage("Error - Could not create in with user.");
} else {
// Test Auth::SignInAnonymously().
{
Future<User*> sign_in_future = auth->SignInAnonymously();
WaitForSignInFuture(sign_in_future, "Auth::SignInAnonymously()",
kAuthErrorNone, auth);
// Test SignOut() after signed in anonymously.
if (sign_in_future.Status() == ::firebase::kFutureStatusComplete) {
auth->SignOut();
if (auth->CurrentUser() != nullptr) {
LogMessage(
"ERROR: CurrentUser() returning %x instead of NULL after "
"SignOut()",
auth->CurrentUser());
}
}
}
// Test Auth::FetchProvidersForEmail().
{
Future<Auth::FetchProvidersResult> providers_future =
auth->FetchProvidersForEmail(user_login.email());
WaitForFuture(providers_future, "Auth::FetchProvidersForEmail()",
kAuthErrorNone);
const Auth::FetchProvidersResult* pro = providers_future.Result();
if (pro) {
LogMessage(" email %s, num providers %d", user_login.email(),
pro->providers.size());
for (auto it = pro->providers.begin(); it != pro->providers.end();
++it) {
LogMessage(" * %s", it->c_str());
}
}
}
// Test Auth::SignInWithEmailAndPassword().
// Sign in with email and password that have already been registered.
{
Future<User*> sign_in_future = auth->SignInWithEmailAndPassword(
user_login.email(), user_login.password());
WaitForSignInFuture(
sign_in_future,
"Auth::SignInWithEmailAndPassword() existing email and password",
kAuthErrorNone, auth);
// Test SignOut() after signed in with email and password.
if (sign_in_future.Status() == ::firebase::kFutureStatusComplete) {
auth->SignOut();
if (auth->CurrentUser() != nullptr) {
LogMessage(
"ERROR: CurrentUser() returning %x instead of NULL after "
"SignOut()",
auth->CurrentUser());
}
}
}
// Sign in user with bad email. Should fail.
{
Future<User*> sign_in_future_bad_email =
auth->SignInWithEmailAndPassword(kTestEmailBad, kTestPassword);
WaitForSignInFuture(sign_in_future_bad_email,
"Auth::SignInWithEmailAndPassword() bad email",
kAuthErrorFailure, auth);
}
// Sign in user with correct email but bad password. Should fail.
{
Future<User*> sign_in_future_bad_password =
auth->SignInWithEmailAndPassword(user_login.email(),
kTestPasswordBad);
WaitForSignInFuture(sign_in_future_bad_password,
"Auth::SignInWithEmailAndPassword() bad password",
kAuthErrorFailure, auth);
}
// Try to create with existing email. Should fail.
{
Future<User*> create_future_bad = auth->CreateUserWithEmailAndPassword(
user_login.email(), user_login.password());
WaitForSignInFuture(
create_future_bad,
"Auth::CreateUserWithEmailAndPassword() existing email",
kAuthErrorFailure, auth);
}
// Test Auth::SignInWithCredential() using email&password.
// Use existing email. Should succeed.
{
Credential email_cred_ok = EmailAuthProvider::GetCredential(
user_login.email(), user_login.password());
Future<User*> sign_in_cred_ok =
auth->SignInWithCredential(email_cred_ok);
WaitForSignInFuture(sign_in_cred_ok,
"Auth::SignInWithCredential() existing email",
kAuthErrorNone, auth);
}
// Use bad Facebook credentials. Should fail.
{
Credential facebook_cred_bad =
FacebookAuthProvider::GetCredential(kTestAccessTokenBad);
Future<User*> facebook_bad =
auth->SignInWithCredential(facebook_cred_bad);
WaitForSignInFuture(
facebook_bad,
"Auth::SignInWithCredential() bad Facebook credentials",
kAuthErrorFailure, auth);
}
// Use bad GitHub credentials. Should fail.
{
Credential git_hub_cred_bad =
GitHubAuthProvider::GetCredential(kTestAccessTokenBad);
Future<User*> git_hub_bad =
auth->SignInWithCredential(git_hub_cred_bad);
WaitForSignInFuture(
git_hub_bad, "Auth::SignInWithCredential() bad GitHub credentials",
kAuthErrorFailure, auth);
}
// Use bad Google credentials. Should fail.
{
Credential google_cred_bad = GoogleAuthProvider::GetCredential(
kTestIdTokenBad, kTestAccessTokenBad);
Future<User*> google_bad = auth->SignInWithCredential(google_cred_bad);
WaitForSignInFuture(
google_bad, "Auth::SignInWithCredential() bad Google credentials",
kAuthErrorFailure, auth);
}
// Use bad Twitter credentials. Should fail.
{
Credential twitter_cred_bad = TwitterAuthProvider::GetCredential(
kTestIdTokenBad, kTestAccessTokenBad);
Future<User*> twitter_bad =
auth->SignInWithCredential(twitter_cred_bad);
WaitForSignInFuture(
twitter_bad, "Auth::SignInWithCredential() bad Twitter credentials",
kAuthErrorFailure, auth);
}
// Test Auth::SendPasswordResetEmail().
// Use existing email. Should succeed.
{
Future<void> send_password_reset_ok =
auth->SendPasswordResetEmail(user_login.email());
WaitForFuture(send_password_reset_ok,
"Auth::SendPasswordResetEmail() existing email",
kAuthErrorNone);
}
// Use bad email. Should fail.
{
Future<void> send_password_reset_bad =
auth->SendPasswordResetEmail(kTestEmailBad);
WaitForFuture(send_password_reset_bad,
"Auth::SendPasswordResetEmail() bad email",
kAuthErrorFailure);
}
}
}
// --- User tests ------------------------------------------------------------
// Test anonymous user info strings.
{
Future<User*> anon_sign_in_for_user = auth->SignInAnonymously();
WaitForSignInFuture(anon_sign_in_for_user,
"Auth::SignInAnonymously() for User", kAuthErrorNone,
auth);
if (anon_sign_in_for_user.Status() == ::firebase::kFutureStatusComplete) {
User* anonymous_user = anon_sign_in_for_user.Result()
? *anon_sign_in_for_user.Result()
: nullptr;
if (anonymous_user != nullptr) {
LogMessage("Anonymous UID is %s", anonymous_user->UID().c_str());
ExpectStringsEqual("Anonymous user Email", "",
anonymous_user->Email().c_str());
ExpectStringsEqual("Anonymous user DisplayName", "",
anonymous_user->DisplayName().c_str());
ExpectStringsEqual("Anonymous user PhotoUrl", "",
anonymous_user->PhotoUrl().c_str());
ExpectStringsEqual("Anonymous user ProviderId", kFirebaseProviderId,
anonymous_user->ProviderId().c_str());
ExpectTrue("Anonymous email Anonymous()", anonymous_user->Anonymous());
// Test User::LinkWithCredential().
const std::string newer_email = CreateNewEmail();
Credential user_cred = EmailAuthProvider::GetCredential(
newer_email.c_str(), kTestPassword);
Future<User*> link_future =
anonymous_user->LinkWithCredential(user_cred);
WaitForSignInFuture(link_future, "User::LinkWithCredential()",
kAuthErrorNone, auth);
UserLogin user_login(auth);
user_login.Register();
if (!user_login.user()) {
LogMessage("Error - Could not create new user.");
} else {
// Test email user info strings.
Future<User*> email_sign_in_for_user =
auth->SignInWithEmailAndPassword(user_login.email(),
user_login.password());
WaitForSignInFuture(email_sign_in_for_user,
"Auth::SignInWithEmailAndPassword() for User",
kAuthErrorNone, auth);
User* email_user = email_sign_in_for_user.Result()
? *email_sign_in_for_user.Result()
: nullptr;
if (email_user != nullptr) {
LogMessage("Email UID is %s", email_user->UID().c_str());
ExpectStringsEqual("Email user Email", user_login.email(),
email_user->Email().c_str());
ExpectStringsEqual("Email user DisplayName", "",
email_user->DisplayName().c_str());
ExpectStringsEqual("Email user PhotoUrl", "",
email_user->PhotoUrl().c_str());
ExpectStringsEqual("Email user ProviderId", kFirebaseProviderId,
email_user->ProviderId().c_str());
ExpectFalse("Email email Anonymous()", email_user->Anonymous());
// Test User::Token().
// with force_refresh = false.
Future<std::string> token_no_refresh = email_user->Token(false);
WaitForFuture(token_no_refresh, "User::Token(false)",
kAuthErrorNone);
LogMessage("User::Token(false) = %s",
token_no_refresh.Result()
? token_no_refresh.Result()->c_str()
: "");
// with force_refresh = true.
Future<std::string> token_force_refresh = email_user->Token(true);
WaitForFuture(token_force_refresh, "User::Token(true)",
kAuthErrorNone);
LogMessage("User::Token(true) = %s",
token_force_refresh.Result()
? token_force_refresh.Result()->c_str()
: "");
// Test Reload().
Future<void> reload_future = email_user->Reload();
WaitForFuture(reload_future, "User::Reload()", kAuthErrorNone);
// Test User::RefreshToken().
const std::string refresh_token = email_user->RefreshToken();
LogMessage("User::RefreshToken() = %s", refresh_token.c_str());
// Test User::Unlink().
Future<User*> unlink_future = email_user->Unlink("firebase");
WaitForSignInFuture(unlink_future, "User::Unlink()",
kAuthErrorFailure, auth);
// Sign in again if user is now invalid.
if (auth->CurrentUser() == nullptr) {
Future<User*> email_sign_in_again =
auth->SignInWithEmailAndPassword(user_login.email(),
user_login.password());
WaitForSignInFuture(email_sign_in_again,
"Auth::SignInWithEmailAndPassword() again",
kAuthErrorNone, auth);
email_user = email_sign_in_again.Result()
? *email_sign_in_again.Result()
: nullptr;
}
}
if (email_user != nullptr) {
// Test User::ProviderData().
const std::vector<UserInfoInterface*>& provider_data =
email_user->ProviderData();
LogMessage("User::ProviderData() returned %d interface%s",
provider_data.size(),
provider_data.size() == 1 ? "" : "s");
for (size_t i = 0; i < provider_data.size(); ++i) {
const UserInfoInterface* user_info = provider_data[i];
LogMessage(
" UID() = %s\n"
" Email() = %s\n"
" DisplayName() = %s\n"
" PhotoUrl() = %s\n"
" ProviderId() = %s",
user_info->UID().c_str(), user_info->Email().c_str(),
user_info->DisplayName().c_str(),
user_info->PhotoUrl().c_str(),
user_info->ProviderId().c_str());
}
// Test User::UpdateEmail().
const std::string newest_email = CreateNewEmail();
Future<void> update_email_future =
email_user->UpdateEmail(newest_email.c_str());
WaitForFuture(update_email_future, "User::UpdateEmail()",
kAuthErrorNone);
// Test User::UpdatePassword().
Future<void> update_password_future =
email_user->UpdatePassword(kTestPasswordUpdated);
WaitForFuture(update_password_future, "User::UpdatePassword()",
kAuthErrorNone);
// Test User::Reauthenticate().
Credential email_cred_reauth = EmailAuthProvider::GetCredential(
newest_email.c_str(), kTestPasswordUpdated);
Future<void> reauthenticate_future =
email_user->Reauthenticate(email_cred_reauth);
WaitForFuture(reauthenticate_future, "User::Reauthenticate()",
kAuthErrorNone);
// Test User::SendEmailVerification().
Future<void> send_email_verification_future =
email_user->SendEmailVerification();
WaitForFuture(
send_email_verification_future, "User::SendEmailVerification()",
#if defined(__ANDROID__)
// Known issue: this method isn't implemented on Android yet.
kAuthErrorUnimplemented);
#else // !defined(__ANDROID__)
kAuthErrorNone);
#endif // !defined(__ANDROID__)
}
}
}
}
// Test User::Delete().
const std::string new_email_for_delete = CreateNewEmail();
Future<User*> create_future_for_delete =
auth->CreateUserWithEmailAndPassword(new_email_for_delete.c_str(),
kTestPassword);
WaitForSignInFuture(
create_future_for_delete,
"Auth::CreateUserWithEmailAndPassword() new email for delete",
kAuthErrorNone, auth);
User* email_user_for_delete = create_future_for_delete.Result()
? *create_future_for_delete.Result()
: nullptr;
if (email_user_for_delete != nullptr) {
Future<void> delete_future = email_user_for_delete->Delete();
WaitForFuture(delete_future, "User::Delete()", kAuthErrorNone);
}
}
LogMessage("Completed Auth tests.");
while (!ProcessEvents(1000)) {
}
delete auth;
delete app;
return 0;
}