@@ -101,9 +101,6 @@ class FirebaseStorageTest : public FirebaseTest {
101
101
void TearDown () override ;
102
102
103
103
protected:
104
- // Root reference for list tests.
105
- firebase::storage::StorageReference list_test_root_;
106
-
107
104
// Initialize Firebase App and Firebase Auth.
108
105
static void InitializeAppAndAuth ();
109
106
// Shut down Firebase App and Firebase Auth.
@@ -230,16 +227,7 @@ void FirebaseStorageTest::TerminateAppAndAuth() {
230
227
void FirebaseStorageTest::SetUp () {
231
228
FirebaseTest::SetUp ();
232
229
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
243
231
}
244
232
245
233
void FirebaseStorageTest::TearDown () {
@@ -1707,23 +1695,21 @@ TEST_F(FirebaseStorageTest, TestInvalidatingReferencesWhenDeletingApp) {
1707
1695
}
1708
1696
1709
1697
TEST_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
1711
1699
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." ;
1713
1702
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.
1717
1703
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" );
1722
1708
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 ());
1725
1711
firebase::Future<firebase::storage::ListResult> future =
1726
- list_all_base .ListAll ();
1712
+ test_root .ListAll ();
1727
1713
WaitForCompletion (future, " ListAllBasic" );
1728
1714
1729
1715
ASSERT_EQ (future.error (), firebase::storage::kErrorNone )
@@ -1737,20 +1723,18 @@ TEST_F(FirebaseStorageTest, ListAllBasic) {
1737
1723
}
1738
1724
1739
1725
TEST_F (FirebaseStorageTest, ListPaginated) {
1740
- SKIP_TEST_ON_ANDROID_EMULATOR;
1726
+ // SKIP_TEST_ON_ANDROID_EMULATOR; // Removed
1741
1727
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." ;
1743
1730
1744
- firebase::storage::StorageReference list_paginated_base =
1745
- list_test_root_.Child (" list_paginated_test" );
1746
- // cleanup_files_.push_back(list_paginated_base);
1747
1731
1748
1732
// 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" );
1754
1738
1755
1739
1756
1740
std::vector<std::string> all_item_names_collected;
@@ -1761,14 +1745,14 @@ TEST_F(FirebaseStorageTest, ListPaginated) {
1761
1745
const int max_pages = 5 ; // Safety break for loop
1762
1746
1763
1747
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);
1765
1749
1766
1750
do {
1767
1751
page_count++;
1768
1752
LogDebug (" Fetching page %d, token: '%s'" , page_count, page_token.c_str ());
1769
1753
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 ());
1772
1756
WaitForCompletion (future, " ListPaginated - Page " + std::to_string (page_count));
1773
1757
1774
1758
ASSERT_EQ (future.error (), firebase::storage::kErrorNone ) << future.error_message ();
@@ -1823,19 +1807,17 @@ TEST_F(FirebaseStorageTest, ListPaginated) {
1823
1807
1824
1808
1825
1809
TEST_F (FirebaseStorageTest, ListEmpty) {
1826
- SKIP_TEST_ON_ANDROID_EMULATOR;
1810
+ // SKIP_TEST_ON_ANDROID_EMULATOR; // No skip needed as it's a lightweight test.
1827
1811
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." ;
1829
1814
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.
1834
1816
1835
1817
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 ());
1837
1819
firebase::Future<firebase::storage::ListResult> future =
1838
- list_empty_ref .ListAll ();
1820
+ test_root .ListAll ();
1839
1821
WaitForCompletion (future, " ListEmpty" );
1840
1822
1841
1823
ASSERT_EQ (future.error (), firebase::storage::kErrorNone )
@@ -1848,22 +1830,20 @@ TEST_F(FirebaseStorageTest, ListEmpty) {
1848
1830
}
1849
1831
1850
1832
TEST_F (FirebaseStorageTest, ListWithMaxResultsGreaterThanActual) {
1851
- SKIP_TEST_ON_ANDROID_EMULATOR;
1833
+ // SKIP_TEST_ON_ANDROID_EMULATOR; // No skip needed.
1852
1834
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." ;
1854
1837
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);
1858
1838
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" );
1861
1841
1862
1842
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 ());
1865
1845
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)
1867
1847
WaitForCompletion (future, " ListWithMaxResultsGreaterThanActual" );
1868
1848
1869
1849
ASSERT_EQ (future.error (), firebase::storage::kErrorNone )
@@ -1876,19 +1856,20 @@ TEST_F(FirebaseStorageTest, ListWithMaxResultsGreaterThanActual) {
1876
1856
}
1877
1857
1878
1858
TEST_F (FirebaseStorageTest, ListNonExistentPath) {
1879
- SKIP_TEST_ON_ANDROID_EMULATOR;
1859
+ // SKIP_TEST_ON_ANDROID_EMULATOR; // No skip needed.
1880
1860
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." ;
1882
1863
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 " );
1885
1866
// No cleanup needed as nothing is created.
1886
1867
1887
1868
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 ());
1890
1871
firebase::Future<firebase::storage::ListResult> future =
1891
- list_non_existent_ref .ListAll ();
1872
+ non_existent_ref .ListAll ();
1892
1873
WaitForCompletion (future, " ListNonExistentPath" );
1893
1874
1894
1875
// Listing a non-existent path should not be an error, it's just an empty list.
0 commit comments