Skip to content

Commit da80bc5

Browse files
authored
Fix Storage test errors on iOS. (#1153)
* Increase large file size for storage tests to reduce flakes, and fix iOS error handling for cancellations. * Fix compile error. * Fix gmock usage, oops.
1 parent 4fb938e commit da80bc5

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

storage/integration_test/src/integration_test.cc

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ const char* kStorageUrl = nullptr;
6262

6363
#if FIREBASE_PLATFORM_DESKTOP
6464
// Use a larger file on desktop...
65-
const int kLargeFileMegabytes = 32;
65+
const int kLargeFileMegabytes = 64;
6666
#else
6767
// ...and a smaller file on mobile.
68-
const int kLargeFileMegabytes = 16;
68+
const int kLargeFileMegabytes = 32;
6969
#endif
7070

7171
const char kRootNodeName[] = "integration_test_data";
@@ -1428,7 +1428,20 @@ TEST_F(FirebaseStorageTest, TestLargeFilePauseResumeAndDownloadCancel) {
14281428

14291429
LogDebug("Cancelling download.");
14301430
EXPECT_TRUE(controller.Cancel());
1431+
#if FIREBASE_PLATFORM_IOS || FIREBASE_PLATFORM_TVOS
1432+
// TODO(b/255839066): Change this to expect kErrorCancelled once iOS SDK
1433+
// returns the correct error code.
1434+
//
1435+
// iOS/tvOS SDK doesn't always report kErrorCancelled, so ensure that
1436+
// either it was reported as cancelled, or the file was not fully uploaded.
1437+
WaitForCompletionAnyResult(future, "GetBytes");
1438+
EXPECT_TRUE(
1439+
future.error() == firebase::storage::kErrorCancelled ||
1440+
future.error() == firebase::storage::kErrorUnknown ||
1441+
(future.error() == 0 && controller.bytes_transferred() < kLargeFileSize));
1442+
#else
14311443
WaitForCompletion(future, "GetBytes", firebase::storage::kErrorCancelled);
1444+
#endif
14321445

14331446
FLAKY_TEST_SECTION_END();
14341447
}
@@ -1464,7 +1477,14 @@ TEST_F(FirebaseStorageTest, TestLargeFileCancelUpload) {
14641477
#if FIREBASE_PLATFORM_IOS || FIREBASE_PLATFORM_TVOS
14651478
// TODO(b/255839066): Change this to expect kErrorCancelled once iOS SDK
14661479
// returns the correct error code.
1467-
WaitForCompletion(future, "PutBytes", firebase::storage::kErrorUnknown);
1480+
//
1481+
// iOS/tvOS SDK doesn't always report kErrorCancelled, so ensure that
1482+
// either it was reported as cancelled, or the file was not fully uploaded.
1483+
WaitForCompletionAnyResult(future, "PutBytes");
1484+
EXPECT_TRUE(
1485+
future.error() == firebase::storage::kErrorCancelled ||
1486+
future.error() == firebase::storage::kErrorUnknown ||
1487+
(future.error() == 0 && controller.bytes_transferred() < kLargeFileSize));
14681488
#else
14691489
WaitForCompletion(future, "PutBytes", firebase::storage::kErrorCancelled);
14701490
#endif // FIREBASE_PLATFORM_IOS || FIREBASE_PLATFORM_TVOS

0 commit comments

Comments
 (0)