@@ -48,23 +48,23 @@ TEST_F(StorageDesktopUtilsTests, testGSStoragePathConstructors) {
4848 StoragePath test_path;
4949
5050 // Test basic case:
51- test_path = StoragePath (" gs://Bucket/path/Object" );
51+ test_path = StoragePath (nullptr , " gs://Bucket/path/Object" );
5252
5353 EXPECT_STREQ (test_path.GetBucket ().c_str (), " Bucket" );
5454 EXPECT_STREQ (test_path.GetPath ().c_str (), " path/Object" );
5555
5656 // Test a more complex path:
57- test_path = StoragePath (" gs://Bucket/path/morepath/Object" );
57+ test_path = StoragePath (nullptr , " gs://Bucket/path/morepath/Object" );
5858 EXPECT_STREQ (test_path.GetBucket ().c_str (), " Bucket" );
5959 EXPECT_STREQ (test_path.GetPath ().c_str (), " path/morepath/Object" );
6060
6161 // Extra slashes:
62- test_path = StoragePath (" gs://Bucket/path////Object" );
62+ test_path = StoragePath (nullptr , " gs://Bucket/path////Object" );
6363 EXPECT_STREQ (test_path.GetBucket ().c_str (), " Bucket" );
6464 EXPECT_STREQ (test_path.GetPath ().c_str (), " path/Object" );
6565
6666 // Path with no Object:
67- test_path = StoragePath (" gs://Bucket/path////more////" );
67+ test_path = StoragePath (nullptr , " gs://Bucket/path////more////" );
6868 EXPECT_STREQ (test_path.GetBucket ().c_str (), " Bucket" );
6969 EXPECT_STREQ (test_path.GetPath ().c_str (), " path/more" );
7070}
@@ -76,29 +76,30 @@ TEST_F(StorageDesktopUtilsTests, testHTTPStoragePathConstructors) {
7676 std::string intended_path_result = " path/to/Object/Object.data" ;
7777
7878 // Test basic case:
79- test_path = StoragePath (
80- " http://firebasestorage.googleapis.com/v0/b/Bucket/o/"
81- " path%2fto%2FObject%2fObject.data" );
79+ test_path = StoragePath (nullptr ,
80+ " http://firebasestorage.googleapis.com/v0/b/Bucket/o/"
81+ " path%2fto%2FObject%2fObject.data" );
8282 EXPECT_STREQ (test_path.GetBucket ().c_str (), intended_bucket_result.c_str ());
8383 EXPECT_STREQ (test_path.GetPath ().c_str (), intended_path_result.c_str ());
8484
8585 // httpS (instead of http):
86- test_path = StoragePath (
87- " https://firebasestorage.googleapis.com/v0/b/Bucket/o/"
88- " path%2fto%2FObject%2fObject.data" );
86+ test_path =
87+ StoragePath (nullptr ,
88+ " https://firebasestorage.googleapis.com/v0/b/Bucket/o/"
89+ " path%2fto%2FObject%2fObject.data" );
8990 EXPECT_STREQ (test_path.GetBucket ().c_str (), intended_bucket_result.c_str ());
9091 EXPECT_STREQ (test_path.GetPath ().c_str (), intended_path_result.c_str ());
9192
9293 // Extra slashes:
93- test_path = StoragePath (
94- " http://firebasestorage.googleapis.com/v0/b/Bucket/o/"
95- " path%2f%2f%2f%2fto%2FObject%2f%2f%2f%2fObject.data" );
94+ test_path = StoragePath (nullptr ,
95+ " http://firebasestorage.googleapis.com/v0/b/Bucket/o/"
96+ " path%2f%2f%2f%2fto%2FObject%2f%2f%2f%2fObject.data" );
9697 EXPECT_STREQ (test_path.GetBucket ().c_str (), intended_bucket_result.c_str ());
9798 EXPECT_STREQ (test_path.GetPath ().c_str (), intended_path_result.c_str ());
9899}
99100
100101TEST_F (StorageDesktopUtilsTests, testInvalidConstructors) {
101- StoragePath bad_path (" argleblargle://Bucket/path1/path2/Object" );
102+ StoragePath bad_path (nullptr , " argleblargle://Bucket/path1/path2/Object" );
102103 EXPECT_FALSE (bad_path.IsValid ());
103104}
104105
@@ -107,12 +108,12 @@ TEST_F(StorageDesktopUtilsTests, testStoragePathParent) {
107108 StoragePath test_path;
108109
109110 // Test parent, when there is an GetObject.
110- test_path = StoragePath (" gs://Bucket/path/Object" ).GetParent ();
111+ test_path = StoragePath (nullptr , " gs://Bucket/path/Object" ).GetParent ();
111112 EXPECT_STREQ (test_path.GetBucket ().c_str (), " Bucket" );
112113 EXPECT_STREQ (test_path.GetPath ().c_str (), " path" );
113114
114115 // Test parent with no GetObject.
115- test_path = StoragePath (" gs://Bucket/path/morepath/" ).GetParent ();
116+ test_path = StoragePath (nullptr , " gs://Bucket/path/morepath/" ).GetParent ();
116117 EXPECT_STREQ (test_path.GetBucket ().c_str (), " Bucket" );
117118 EXPECT_STREQ (test_path.GetPath ().c_str (), " path" );
118119}
@@ -122,27 +123,32 @@ TEST_F(StorageDesktopUtilsTests, testStoragePathChild) {
122123 StoragePath test_path;
123124
124125 // Test child when there is no object.
125- test_path = StoragePath (" gs://Bucket/path/morepath/" ).GetChild (" newobj" );
126+ test_path =
127+ StoragePath (nullptr , " gs://Bucket/path/morepath/" ).GetChild (" newobj" );
126128 EXPECT_STREQ (test_path.GetBucket ().c_str (), " Bucket" );
127129 EXPECT_STREQ (test_path.GetPath ().c_str (), " path/morepath/newobj" );
128130
129131 // Test child when there is an object.
130- test_path = StoragePath (" gs://Bucket/path/object" ).GetChild (" newpath/" );
132+ test_path =
133+ StoragePath (nullptr , " gs://Bucket/path/object" ).GetChild (" newpath/" );
131134 EXPECT_STREQ (test_path.GetBucket ().c_str (), " Bucket" );
132135 EXPECT_STREQ (test_path.GetPath ().c_str (), " path/object/newpath" );
133136}
134137
135138TEST_F (StorageDesktopUtilsTests, testUrlConverter) {
136- StoragePath test_path (" gs://Bucket/path1/path2/Object" );
139+ std::unique_ptr<App> app (firebase::testing::CreateApp ());
140+ StorageInternal* storage = new StorageInternal (app.get (), " gs://Bucket" );
141+
142+ StoragePath test_path (storage, " gs://Bucket/path1/path2/Object" );
137143
138144 EXPECT_STREQ (test_path.GetBucket ().c_str (), " Bucket" );
139145 EXPECT_STREQ (test_path.GetPath ().c_str (), " path1/path2/Object" );
140146
141147 EXPECT_STREQ (test_path.AsHttpUrl ().c_str (),
142- " https://firebasestorage.googleapis.com"
148+ " https://firebasestorage.googleapis.com:443 "
143149 " /v0/b/Bucket/o/path1%2Fpath2%2FObject?alt=media" );
144150 EXPECT_STREQ (test_path.AsHttpMetadataUrl ().c_str (),
145- " https://firebasestorage.googleapis.com"
151+ " https://firebasestorage.googleapis.com:443 "
146152 " /v0/b/Bucket/o/path1%2Fpath2%2FObject" );
147153}
148154
0 commit comments