@@ -101,9 +101,6 @@ class FirebaseStorageTest : public FirebaseTest {
101101 void TearDown () override ;
102102
103103 protected:
104- // Root reference for list tests.
105- firebase::storage::StorageReference list_test_root_;
106-
107104 // Initialize Firebase App and Firebase Auth.
108105 static void InitializeAppAndAuth ();
109106 // Shut down Firebase App and Firebase Auth.
@@ -230,16 +227,7 @@ void FirebaseStorageTest::TerminateAppAndAuth() {
230227void FirebaseStorageTest::SetUp () {
231228 FirebaseTest::SetUp ();
232229 InitializeStorage ();
233- if (storage_ != nullptr && storage_->GetReference ().is_valid ()) {
234- list_test_root_ = CreateFolder ().Child (" list_tests_root" );
235- // list_test_root_ itself doesn't need to be in cleanup_files_ if its parent from CreateFolder() is.
236- // However, specific files/folders created under list_test_root_ for each test *will* be added
237- // via UploadStringAsFile or by explicitly adding the parent of a set of files for that test.
238- } else {
239- // Handle cases where storage might not be initialized (e.g. if InitializeStorage fails)
240- // by providing a default, invalid reference.
241- list_test_root_ = firebase::storage::StorageReference ();
242- }
230+ // list_test_root_ removed from SetUp
243231}
244232
245233void FirebaseStorageTest::TearDown () {
@@ -1707,23 +1695,21 @@ TEST_F(FirebaseStorageTest, TestInvalidatingReferencesWhenDeletingApp) {
17071695}
17081696
17091697TEST_F (FirebaseStorageTest, ListAllBasic) {
1710- SKIP_TEST_ON_ANDROID_EMULATOR; // List tests can be slow on emulators or have quota issues.
1698+ // SKIP_TEST_ON_ANDROID_EMULATOR; // Removed
17111699 SignIn ();
1712- ASSERT_TRUE (list_test_root_.is_valid ()) << " List test root is not valid." ;
1700+ firebase::storage::StorageReference test_root = CreateFolder ().Child (" list_all_basic_root" );
1701+ ASSERT_TRUE (test_root.is_valid ()) << " Test root for ListAllBasic is not valid." ;
17131702
1714- firebase::storage::StorageReference list_all_base =
1715- list_test_root_.Child (" list_all_basic_test" );
1716- // cleanup_files_.push_back(list_all_base); // Not a file, its contents are files.
17171703
1718- UploadStringAsFile (list_all_base .Child (" file_a.txt" ), " content_a" );
1719- UploadStringAsFile (list_all_base .Child (" file_b.txt" ), " content_b" );
1720- UploadStringAsFile (list_all_base .Child (" prefix1/file_c.txt" ), " content_c_in_prefix1" );
1721- UploadStringAsFile (list_all_base .Child (" prefix2/file_e.txt" ), " content_e_in_prefix2" );
1704+ UploadStringAsFile (test_root .Child (" file_a.txt" ), " content_a" );
1705+ UploadStringAsFile (test_root .Child (" file_b.txt" ), " content_b" );
1706+ UploadStringAsFile (test_root .Child (" prefix1/file_c.txt" ), " content_c_in_prefix1" );
1707+ UploadStringAsFile (test_root .Child (" prefix2/file_e.txt" ), " content_e_in_prefix2" );
17221708
1723- LogDebug (" Calling ListAll() on gs://%s%s" , list_all_base .bucket ().c_str (),
1724- list_all_base .full_path ().c_str ());
1709+ LogDebug (" Calling ListAll() on gs://%s%s" , test_root .bucket ().c_str (),
1710+ test_root .full_path ().c_str ());
17251711 firebase::Future<firebase::storage::ListResult> future =
1726- list_all_base .ListAll ();
1712+ test_root .ListAll ();
17271713 WaitForCompletion (future, " ListAllBasic" );
17281714
17291715 ASSERT_EQ (future.error (), firebase::storage::kErrorNone )
@@ -1737,20 +1723,18 @@ TEST_F(FirebaseStorageTest, ListAllBasic) {
17371723}
17381724
17391725TEST_F (FirebaseStorageTest, ListPaginated) {
1740- SKIP_TEST_ON_ANDROID_EMULATOR;
1726+ // SKIP_TEST_ON_ANDROID_EMULATOR; // Removed
17411727 SignIn ();
1742- ASSERT_TRUE (list_test_root_.is_valid ()) << " List test root is not valid." ;
1728+ firebase::storage::StorageReference test_root = CreateFolder ().Child (" list_paginated_root" );
1729+ ASSERT_TRUE (test_root.is_valid ()) << " Test root for ListPaginated is not valid." ;
17431730
1744- firebase::storage::StorageReference list_paginated_base =
1745- list_test_root_.Child (" list_paginated_test" );
1746- // cleanup_files_.push_back(list_paginated_base);
17471731
17481732 // Expected total entries: file_aa.txt, file_bb.txt, file_ee.txt, prefix_x/, prefix_y/ (5 entries)
1749- UploadStringAsFile (list_paginated_base .Child (" file_aa.txt" ), " content_aa" );
1750- UploadStringAsFile (list_paginated_base .Child (" prefix_x/file_cc.txt" ), " content_cc_in_prefix_x" );
1751- UploadStringAsFile (list_paginated_base .Child (" file_bb.txt" ), " content_bb" );
1752- UploadStringAsFile (list_paginated_base .Child (" prefix_y/file_dd.txt" ), " content_dd_in_prefix_y" );
1753- UploadStringAsFile (list_paginated_base .Child (" file_ee.txt" ), " content_ee" );
1733+ UploadStringAsFile (test_root .Child (" file_aa.txt" ), " content_aa" );
1734+ UploadStringAsFile (test_root .Child (" prefix_x/file_cc.txt" ), " content_cc_in_prefix_x" );
1735+ UploadStringAsFile (test_root .Child (" file_bb.txt" ), " content_bb" );
1736+ UploadStringAsFile (test_root .Child (" prefix_y/file_dd.txt" ), " content_dd_in_prefix_y" );
1737+ UploadStringAsFile (test_root .Child (" file_ee.txt" ), " content_ee" );
17541738
17551739
17561740 std::vector<std::string> all_item_names_collected;
@@ -1761,14 +1745,14 @@ TEST_F(FirebaseStorageTest, ListPaginated) {
17611745 const int max_pages = 5 ; // Safety break for loop
17621746
17631747 LogDebug (" Starting paginated List() on gs://%s%s with page_size %d" ,
1764- list_paginated_base .bucket ().c_str (), list_paginated_base .full_path ().c_str (), page_size);
1748+ test_root .bucket ().c_str (), test_root .full_path ().c_str (), page_size);
17651749
17661750 do {
17671751 page_count++;
17681752 LogDebug (" Fetching page %d, token: '%s'" , page_count, page_token.c_str ());
17691753 firebase::Future<firebase::storage::ListResult> future =
1770- page_token.empty () ? list_paginated_base .List (page_size)
1771- : list_paginated_base .List (page_size, page_token.c_str ());
1754+ page_token.empty () ? test_root .List (page_size)
1755+ : test_root .List (page_size, page_token.c_str ());
17721756 WaitForCompletion (future, " ListPaginated - Page " + std::to_string (page_count));
17731757
17741758 ASSERT_EQ (future.error (), firebase::storage::kErrorNone ) << future.error_message ();
@@ -1823,19 +1807,17 @@ TEST_F(FirebaseStorageTest, ListPaginated) {
18231807
18241808
18251809TEST_F (FirebaseStorageTest, ListEmpty) {
1826- SKIP_TEST_ON_ANDROID_EMULATOR;
1810+ // SKIP_TEST_ON_ANDROID_EMULATOR; // No skip needed as it's a lightweight test.
18271811 SignIn ();
1828- ASSERT_TRUE (list_test_root_.is_valid ()) << " List test root is not valid." ;
1812+ firebase::storage::StorageReference test_root = CreateFolder ().Child (" list_empty_root" );
1813+ ASSERT_TRUE (test_root.is_valid ()) << " Test root for ListEmpty is not valid." ;
18291814
1830- firebase::storage::StorageReference list_empty_ref =
1831- list_test_root_.Child (" list_empty_folder_test" );
1832- // Do not upload anything to this reference.
1833- // cleanup_files_.push_back(list_empty_ref); // Not a file
1815+ // Do not upload anything to test_root.
18341816
18351817 LogDebug (" Calling ListAll() on empty folder: gs://%s%s" ,
1836- list_empty_ref .bucket ().c_str (), list_empty_ref .full_path ().c_str ());
1818+ test_root .bucket ().c_str (), test_root .full_path ().c_str ());
18371819 firebase::Future<firebase::storage::ListResult> future =
1838- list_empty_ref .ListAll ();
1820+ test_root .ListAll ();
18391821 WaitForCompletion (future, " ListEmpty" );
18401822
18411823 ASSERT_EQ (future.error (), firebase::storage::kErrorNone )
@@ -1848,22 +1830,20 @@ TEST_F(FirebaseStorageTest, ListEmpty) {
18481830}
18491831
18501832TEST_F (FirebaseStorageTest, ListWithMaxResultsGreaterThanActual) {
1851- SKIP_TEST_ON_ANDROID_EMULATOR;
1833+ // SKIP_TEST_ON_ANDROID_EMULATOR; // No skip needed.
18521834 SignIn ();
1853- ASSERT_TRUE (list_test_root_.is_valid ()) << " List test root is not valid." ;
1835+ firebase::storage::StorageReference test_root = CreateFolder ().Child (" list_max_greater_root" );
1836+ ASSERT_TRUE (test_root.is_valid ()) << " Test root for ListWithMaxResultsGreaterThanActual is not valid." ;
18541837
1855- firebase::storage::StorageReference list_max_greater_base =
1856- list_test_root_.Child (" list_max_greater_test" );
1857- // cleanup_files_.push_back(list_max_greater_base);
18581838
1859- UploadStringAsFile (list_max_greater_base .Child (" only_file.txt" ), " content_only" );
1860- UploadStringAsFile (list_max_greater_base .Child (" only_prefix/another.txt" ), " content_another_in_prefix" );
1839+ UploadStringAsFile (test_root .Child (" only_file.txt" ), " content_only" );
1840+ UploadStringAsFile (test_root .Child (" only_prefix/another.txt" ), " content_another_in_prefix" );
18611841
18621842 LogDebug (" Calling List(10) on gs://%s%s" ,
1863- list_max_greater_base .bucket ().c_str (),
1864- list_max_greater_base .full_path ().c_str ());
1843+ test_root .bucket ().c_str (),
1844+ test_root .full_path ().c_str ());
18651845 firebase::Future<firebase::storage::ListResult> future =
1866- list_max_greater_base .List (10 ); // Max results (10) > actual (1 file + 1 prefix = 2)
1846+ test_root .List (10 ); // Max results (10) > actual (1 file + 1 prefix = 2)
18671847 WaitForCompletion (future, " ListWithMaxResultsGreaterThanActual" );
18681848
18691849 ASSERT_EQ (future.error (), firebase::storage::kErrorNone )
@@ -1876,19 +1856,20 @@ TEST_F(FirebaseStorageTest, ListWithMaxResultsGreaterThanActual) {
18761856}
18771857
18781858TEST_F (FirebaseStorageTest, ListNonExistentPath) {
1879- SKIP_TEST_ON_ANDROID_EMULATOR;
1859+ // SKIP_TEST_ON_ANDROID_EMULATOR; // No skip needed.
18801860 SignIn ();
1881- ASSERT_TRUE (list_test_root_.is_valid ()) << " List test root is not valid." ;
1861+ firebase::storage::StorageReference test_root = CreateFolder ().Child (" list_non_existent_parent_root" );
1862+ ASSERT_TRUE (test_root.is_valid ()) << " Test root for ListNonExistentPath is not valid." ;
18821863
1883- firebase::storage::StorageReference list_non_existent_ref =
1884- list_test_root_ .Child (" this_folder_does_not_exist_for_list_test " );
1864+ firebase::storage::StorageReference non_existent_ref =
1865+ test_root .Child (" this_folder_truly_does_not_exist " );
18851866 // No cleanup needed as nothing is created.
18861867
18871868 LogDebug (" Calling ListAll() on non-existent path: gs://%s%s" ,
1888- list_non_existent_ref .bucket ().c_str (),
1889- list_non_existent_ref .full_path ().c_str ());
1869+ non_existent_ref .bucket ().c_str (),
1870+ non_existent_ref .full_path ().c_str ());
18901871 firebase::Future<firebase::storage::ListResult> future =
1891- list_non_existent_ref .ListAll ();
1872+ non_existent_ref .ListAll ();
18921873 WaitForCompletion (future, " ListNonExistentPath" );
18931874
18941875 // Listing a non-existent path should not be an error, it's just an empty list.
0 commit comments