OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/google_apis/fake_drive_service.h" | 5 #include "chrome/browser/google_apis/fake_drive_service.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 }; | 89 }; |
90 | 90 |
91 TEST_F(FakeDriveServiceTest, GetResourceList_All) { | 91 TEST_F(FakeDriveServiceTest, GetResourceList_All) { |
92 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 92 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( |
93 "chromeos/gdata/root_feed.json")); | 93 "chromeos/gdata/root_feed.json")); |
94 | 94 |
95 GDataErrorCode error = GDATA_OTHER_ERROR; | 95 GDataErrorCode error = GDATA_OTHER_ERROR; |
96 scoped_ptr<ResourceList> resource_list; | 96 scoped_ptr<ResourceList> resource_list; |
97 fake_service_.GetResourceList( | 97 fake_service_.GetResourceList( |
98 GURL(), | 98 GURL(), |
99 0, // start_changestamp | 99 0, // start_changestamp |
100 "", // search_query | 100 std::string(), // search_query |
101 "", // directory_resource_id | 101 std::string(), // directory_resource_id |
102 test_util::CreateCopyResultCallback(&error, &resource_list)); | 102 test_util::CreateCopyResultCallback(&error, &resource_list)); |
103 message_loop_.RunUntilIdle(); | 103 message_loop_.RunUntilIdle(); |
104 | 104 |
105 EXPECT_EQ(HTTP_SUCCESS, error); | 105 EXPECT_EQ(HTTP_SUCCESS, error); |
106 ASSERT_TRUE(resource_list); | 106 ASSERT_TRUE(resource_list); |
107 // Do some sanity check. | 107 // Do some sanity check. |
108 EXPECT_EQ(14U, resource_list->entries().size()); | 108 EXPECT_EQ(14U, resource_list->entries().size()); |
109 EXPECT_EQ(1, fake_service_.resource_list_load_count()); | 109 EXPECT_EQ(1, fake_service_.resource_list_load_count()); |
110 } | 110 } |
111 | 111 |
112 TEST_F(FakeDriveServiceTest, GetResourceList_WithStartIndex) { | 112 TEST_F(FakeDriveServiceTest, GetResourceList_WithStartIndex) { |
113 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 113 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( |
114 "chromeos/gdata/root_feed.json")); | 114 "chromeos/gdata/root_feed.json")); |
115 | 115 |
116 GDataErrorCode error = GDATA_OTHER_ERROR; | 116 GDataErrorCode error = GDATA_OTHER_ERROR; |
117 scoped_ptr<ResourceList> resource_list; | 117 scoped_ptr<ResourceList> resource_list; |
118 fake_service_.GetResourceList( | 118 fake_service_.GetResourceList( |
119 GURL("http://dummyurl/?start-offset=2"), | 119 GURL("http://dummyurl/?start-offset=2"), |
120 0, // start_changestamp | 120 0, // start_changestamp |
121 "", // search_query | 121 std::string(), // search_query |
122 "", // directory_resource_id | 122 std::string(), // directory_resource_id |
123 test_util::CreateCopyResultCallback(&error, &resource_list)); | 123 test_util::CreateCopyResultCallback(&error, &resource_list)); |
124 message_loop_.RunUntilIdle(); | 124 message_loop_.RunUntilIdle(); |
125 | 125 |
126 EXPECT_EQ(HTTP_SUCCESS, error); | 126 EXPECT_EQ(HTTP_SUCCESS, error); |
127 ASSERT_TRUE(resource_list); | 127 ASSERT_TRUE(resource_list); |
128 // Because the start-offset was set to 2, the size should be 12 instead of | 128 // Because the start-offset was set to 2, the size should be 12 instead of |
129 // 14 (the total number). | 129 // 14 (the total number). |
130 EXPECT_EQ(12U, resource_list->entries().size()); | 130 EXPECT_EQ(12U, resource_list->entries().size()); |
131 EXPECT_EQ(1, fake_service_.resource_list_load_count()); | 131 EXPECT_EQ(1, fake_service_.resource_list_load_count()); |
132 } | 132 } |
133 | 133 |
134 TEST_F(FakeDriveServiceTest, GetResourceList_WithStartIndexAndMaxResults) { | 134 TEST_F(FakeDriveServiceTest, GetResourceList_WithStartIndexAndMaxResults) { |
135 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 135 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( |
136 "chromeos/gdata/root_feed.json")); | 136 "chromeos/gdata/root_feed.json")); |
137 | 137 |
138 GDataErrorCode error = GDATA_OTHER_ERROR; | 138 GDataErrorCode error = GDATA_OTHER_ERROR; |
139 scoped_ptr<ResourceList> resource_list; | 139 scoped_ptr<ResourceList> resource_list; |
140 fake_service_.GetResourceList( | 140 fake_service_.GetResourceList( |
141 GURL("http://localhost/?start-offset=2&max-results=5"), | 141 GURL("http://localhost/?start-offset=2&max-results=5"), |
142 0, // start_changestamp | 142 0, // start_changestamp |
143 "", // search_query | 143 std::string(), // search_query |
144 "", // directory_resource_id | 144 std::string(), // directory_resource_id |
145 test_util::CreateCopyResultCallback(&error, &resource_list)); | 145 test_util::CreateCopyResultCallback(&error, &resource_list)); |
146 message_loop_.RunUntilIdle(); | 146 message_loop_.RunUntilIdle(); |
147 | 147 |
148 EXPECT_EQ(HTTP_SUCCESS, error); | 148 EXPECT_EQ(HTTP_SUCCESS, error); |
149 ASSERT_TRUE(resource_list); | 149 ASSERT_TRUE(resource_list); |
150 // Because the max-results was set to 5, the size should be 5 instead of 10. | 150 // Because the max-results was set to 5, the size should be 5 instead of 10. |
151 EXPECT_EQ(5U, resource_list->entries().size()); | 151 EXPECT_EQ(5U, resource_list->entries().size()); |
152 EXPECT_EQ(1, fake_service_.resource_list_load_count()); | 152 EXPECT_EQ(1, fake_service_.resource_list_load_count()); |
153 // The next link should be provided. The new start-offset should be | 153 // The next link should be provided. The new start-offset should be |
154 // 2 (original start index) + 5 (max results). | 154 // 2 (original start index) + 5 (max results). |
155 const google_apis::Link* next_link = | 155 const google_apis::Link* next_link = |
156 resource_list->GetLinkByType(Link::LINK_NEXT); | 156 resource_list->GetLinkByType(Link::LINK_NEXT); |
157 ASSERT_TRUE(next_link); | 157 ASSERT_TRUE(next_link); |
158 EXPECT_EQ(GURL("http://localhost/?start-offset=7&max-results=5"), | 158 EXPECT_EQ(GURL("http://localhost/?start-offset=7&max-results=5"), |
159 next_link->href()); | 159 next_link->href()); |
160 } | 160 } |
161 | 161 |
162 TEST_F(FakeDriveServiceTest, GetResourceList_WithDefaultMaxResultsChanged) { | 162 TEST_F(FakeDriveServiceTest, GetResourceList_WithDefaultMaxResultsChanged) { |
163 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 163 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( |
164 "chromeos/gdata/root_feed.json")); | 164 "chromeos/gdata/root_feed.json")); |
165 fake_service_.set_default_max_results(3); | 165 fake_service_.set_default_max_results(3); |
166 | 166 |
167 GDataErrorCode error = GDATA_OTHER_ERROR; | 167 GDataErrorCode error = GDATA_OTHER_ERROR; |
168 scoped_ptr<ResourceList> resource_list; | 168 scoped_ptr<ResourceList> resource_list; |
169 fake_service_.GetResourceList( | 169 fake_service_.GetResourceList( |
170 GURL(), | 170 GURL(), |
171 0, // start_changestamp | 171 0, // start_changestamp |
172 "", // search_query | 172 std::string(), // search_query |
173 "", // directory_resource_id | 173 std::string(), // directory_resource_id |
174 test_util::CreateCopyResultCallback(&error, &resource_list)); | 174 test_util::CreateCopyResultCallback(&error, &resource_list)); |
175 message_loop_.RunUntilIdle(); | 175 message_loop_.RunUntilIdle(); |
176 | 176 |
177 EXPECT_EQ(HTTP_SUCCESS, error); | 177 EXPECT_EQ(HTTP_SUCCESS, error); |
178 ASSERT_TRUE(resource_list); | 178 ASSERT_TRUE(resource_list); |
179 // Because the default max results was changed to 3, the size should be 3 | 179 // Because the default max results was changed to 3, the size should be 3 |
180 // instead of 12 (the total number). | 180 // instead of 12 (the total number). |
181 EXPECT_EQ(3U, resource_list->entries().size()); | 181 EXPECT_EQ(3U, resource_list->entries().size()); |
182 EXPECT_EQ(1, fake_service_.resource_list_load_count()); | 182 EXPECT_EQ(1, fake_service_.resource_list_load_count()); |
183 // The next link should be provided. | 183 // The next link should be provided. |
184 const google_apis::Link* next_link = | 184 const google_apis::Link* next_link = |
185 resource_list->GetLinkByType(Link::LINK_NEXT); | 185 resource_list->GetLinkByType(Link::LINK_NEXT); |
186 ASSERT_TRUE(next_link); | 186 ASSERT_TRUE(next_link); |
187 EXPECT_EQ(GURL("http://localhost/?start-offset=3&max-results=3"), | 187 EXPECT_EQ(GURL("http://localhost/?start-offset=3&max-results=3"), |
188 next_link->href()); | 188 next_link->href()); |
189 } | 189 } |
190 | 190 |
191 TEST_F(FakeDriveServiceTest, GetResourceList_InRootDirectory) { | 191 TEST_F(FakeDriveServiceTest, GetResourceList_InRootDirectory) { |
192 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 192 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( |
193 "chromeos/gdata/root_feed.json")); | 193 "chromeos/gdata/root_feed.json")); |
194 | 194 |
195 GDataErrorCode error = GDATA_OTHER_ERROR; | 195 GDataErrorCode error = GDATA_OTHER_ERROR; |
196 scoped_ptr<ResourceList> resource_list; | 196 scoped_ptr<ResourceList> resource_list; |
197 fake_service_.GetResourceList( | 197 fake_service_.GetResourceList( |
198 GURL(), | 198 GURL(), |
199 0, // start_changestamp | 199 0, // start_changestamp |
200 "", // search_query | 200 std::string(), // search_query |
201 fake_service_.GetRootResourceId(), // directory_resource_id | 201 fake_service_.GetRootResourceId(), // directory_resource_id |
202 test_util::CreateCopyResultCallback(&error, &resource_list)); | 202 test_util::CreateCopyResultCallback(&error, &resource_list)); |
203 message_loop_.RunUntilIdle(); | 203 message_loop_.RunUntilIdle(); |
204 | 204 |
205 EXPECT_EQ(HTTP_SUCCESS, error); | 205 EXPECT_EQ(HTTP_SUCCESS, error); |
206 ASSERT_TRUE(resource_list); | 206 ASSERT_TRUE(resource_list); |
207 // Do some sanity check. There are 7 entries in the root directory. | 207 // Do some sanity check. There are 7 entries in the root directory. |
208 EXPECT_EQ(8U, resource_list->entries().size()); | 208 EXPECT_EQ(8U, resource_list->entries().size()); |
209 EXPECT_EQ(1, fake_service_.resource_list_load_count()); | 209 EXPECT_EQ(1, fake_service_.resource_list_load_count()); |
210 } | 210 } |
211 | 211 |
212 TEST_F(FakeDriveServiceTest, GetResourceList_Search) { | 212 TEST_F(FakeDriveServiceTest, GetResourceList_Search) { |
213 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 213 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( |
214 "chromeos/gdata/root_feed.json")); | 214 "chromeos/gdata/root_feed.json")); |
215 | 215 |
216 GDataErrorCode error = GDATA_OTHER_ERROR; | 216 GDataErrorCode error = GDATA_OTHER_ERROR; |
217 scoped_ptr<ResourceList> resource_list; | 217 scoped_ptr<ResourceList> resource_list; |
218 fake_service_.GetResourceList( | 218 fake_service_.GetResourceList( |
219 GURL(), | 219 GURL(), |
220 0, // start_changestamp | 220 0, // start_changestamp |
221 "File", // search_query | 221 "File", // search_query |
222 "", // directory_resource_id | 222 std::string(), // directory_resource_id |
223 test_util::CreateCopyResultCallback(&error, &resource_list)); | 223 test_util::CreateCopyResultCallback(&error, &resource_list)); |
224 message_loop_.RunUntilIdle(); | 224 message_loop_.RunUntilIdle(); |
225 | 225 |
226 EXPECT_EQ(HTTP_SUCCESS, error); | 226 EXPECT_EQ(HTTP_SUCCESS, error); |
227 ASSERT_TRUE(resource_list); | 227 ASSERT_TRUE(resource_list); |
228 // Do some sanity check. There are 4 entries that contain "File" in their | 228 // Do some sanity check. There are 4 entries that contain "File" in their |
229 // titles. | 229 // titles. |
230 EXPECT_EQ(4U, resource_list->entries().size()); | 230 EXPECT_EQ(4U, resource_list->entries().size()); |
231 EXPECT_EQ(1, fake_service_.resource_list_load_count()); | 231 EXPECT_EQ(1, fake_service_.resource_list_load_count()); |
232 } | 232 } |
233 | 233 |
234 TEST_F(FakeDriveServiceTest, GetResourceList_SearchWithAttribute) { | 234 TEST_F(FakeDriveServiceTest, GetResourceList_SearchWithAttribute) { |
235 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 235 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( |
236 "chromeos/gdata/root_feed.json")); | 236 "chromeos/gdata/root_feed.json")); |
237 | 237 |
238 GDataErrorCode error = GDATA_OTHER_ERROR; | 238 GDataErrorCode error = GDATA_OTHER_ERROR; |
239 scoped_ptr<ResourceList> resource_list; | 239 scoped_ptr<ResourceList> resource_list; |
240 fake_service_.GetResourceList( | 240 fake_service_.GetResourceList( |
241 GURL(), | 241 GURL(), |
242 0, // start_changestamp | 242 0, // start_changestamp |
243 "title:1.txt", // search_query | 243 "title:1.txt", // search_query |
244 "", // directory_resource_id | 244 std::string(), // directory_resource_id |
245 test_util::CreateCopyResultCallback(&error, &resource_list)); | 245 test_util::CreateCopyResultCallback(&error, &resource_list)); |
246 message_loop_.RunUntilIdle(); | 246 message_loop_.RunUntilIdle(); |
247 | 247 |
248 EXPECT_EQ(HTTP_SUCCESS, error); | 248 EXPECT_EQ(HTTP_SUCCESS, error); |
249 ASSERT_TRUE(resource_list); | 249 ASSERT_TRUE(resource_list); |
250 // Do some sanity check. There are 4 entries that contain "1.txt" in their | 250 // Do some sanity check. There are 4 entries that contain "1.txt" in their |
251 // titles. | 251 // titles. |
252 EXPECT_EQ(4U, resource_list->entries().size()); | 252 EXPECT_EQ(4U, resource_list->entries().size()); |
253 EXPECT_EQ(1, fake_service_.resource_list_load_count()); | 253 EXPECT_EQ(1, fake_service_.resource_list_load_count()); |
254 } | 254 } |
255 | 255 |
256 TEST_F(FakeDriveServiceTest, GetResourceList_SearchMultipleQueries) { | 256 TEST_F(FakeDriveServiceTest, GetResourceList_SearchMultipleQueries) { |
257 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 257 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( |
258 "chromeos/gdata/root_feed.json")); | 258 "chromeos/gdata/root_feed.json")); |
259 | 259 |
260 GDataErrorCode error = GDATA_OTHER_ERROR; | 260 GDataErrorCode error = GDATA_OTHER_ERROR; |
261 scoped_ptr<ResourceList> resource_list; | 261 scoped_ptr<ResourceList> resource_list; |
262 fake_service_.GetResourceList( | 262 fake_service_.GetResourceList( |
263 GURL(), | 263 GURL(), |
264 0, // start_changestamp | 264 0, // start_changestamp |
265 "Directory 1", // search_query | 265 "Directory 1", // search_query |
266 "", // directory_resource_id | 266 std::string(), // directory_resource_id |
267 test_util::CreateCopyResultCallback(&error, &resource_list)); | 267 test_util::CreateCopyResultCallback(&error, &resource_list)); |
268 message_loop_.RunUntilIdle(); | 268 message_loop_.RunUntilIdle(); |
269 | 269 |
270 EXPECT_EQ(HTTP_SUCCESS, error); | 270 EXPECT_EQ(HTTP_SUCCESS, error); |
271 ASSERT_TRUE(resource_list); | 271 ASSERT_TRUE(resource_list); |
272 // There are 2 entries that contain both "Directory" and "1" in their titles. | 272 // There are 2 entries that contain both "Directory" and "1" in their titles. |
273 EXPECT_EQ(2U, resource_list->entries().size()); | 273 EXPECT_EQ(2U, resource_list->entries().size()); |
274 | 274 |
275 fake_service_.GetResourceList( | 275 fake_service_.GetResourceList( |
276 GURL(), | 276 GURL(), |
277 0, // start_changestamp | 277 0, // start_changestamp |
278 "\"Directory 1\"", // search_query | 278 "\"Directory 1\"", // search_query |
279 "", // directory_resource_id | 279 std::string(), // directory_resource_id |
280 test_util::CreateCopyResultCallback(&error, &resource_list)); | 280 test_util::CreateCopyResultCallback(&error, &resource_list)); |
281 message_loop_.RunUntilIdle(); | 281 message_loop_.RunUntilIdle(); |
282 | 282 |
283 EXPECT_EQ(HTTP_SUCCESS, error); | 283 EXPECT_EQ(HTTP_SUCCESS, error); |
284 ASSERT_TRUE(resource_list); | 284 ASSERT_TRUE(resource_list); |
285 // There is 1 entry that contain "Directory 1" in its title. | 285 // There is 1 entry that contain "Directory 1" in its title. |
286 EXPECT_EQ(1U, resource_list->entries().size()); | 286 EXPECT_EQ(1U, resource_list->entries().size()); |
287 EXPECT_EQ(2, fake_service_.resource_list_load_count()); | 287 EXPECT_EQ(2, fake_service_.resource_list_load_count()); |
288 } | 288 } |
289 | 289 |
290 TEST_F(FakeDriveServiceTest, GetResourceList_NoNewEntries) { | 290 TEST_F(FakeDriveServiceTest, GetResourceList_NoNewEntries) { |
291 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 291 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( |
292 "chromeos/gdata/root_feed.json")); | 292 "chromeos/gdata/root_feed.json")); |
293 // Load the account_metadata.json as well to add the largest changestamp | 293 // Load the account_metadata.json as well to add the largest changestamp |
294 // (654321) to the existing entries. | 294 // (654321) to the existing entries. |
295 ASSERT_TRUE(fake_service_.LoadAccountMetadataForWapi( | 295 ASSERT_TRUE(fake_service_.LoadAccountMetadataForWapi( |
296 "chromeos/gdata/account_metadata.json")); | 296 "chromeos/gdata/account_metadata.json")); |
297 | 297 |
298 GDataErrorCode error = GDATA_OTHER_ERROR; | 298 GDataErrorCode error = GDATA_OTHER_ERROR; |
299 scoped_ptr<ResourceList> resource_list; | 299 scoped_ptr<ResourceList> resource_list; |
300 fake_service_.GetResourceList( | 300 fake_service_.GetResourceList( |
301 GURL(), | 301 GURL(), |
302 654321 + 1, // start_changestamp | 302 654321 + 1, // start_changestamp |
303 "", // search_query | 303 std::string(), // search_query |
304 "", // directory_resource_id | 304 std::string(), // directory_resource_id |
305 test_util::CreateCopyResultCallback(&error, &resource_list)); | 305 test_util::CreateCopyResultCallback(&error, &resource_list)); |
306 message_loop_.RunUntilIdle(); | 306 message_loop_.RunUntilIdle(); |
307 | 307 |
308 EXPECT_EQ(HTTP_SUCCESS, error); | 308 EXPECT_EQ(HTTP_SUCCESS, error); |
309 ASSERT_TRUE(resource_list); | 309 ASSERT_TRUE(resource_list); |
310 // This should be empty as the latest changestamp was passed to | 310 // This should be empty as the latest changestamp was passed to |
311 // GetResourceList(), hence there should be no new entries. | 311 // GetResourceList(), hence there should be no new entries. |
312 EXPECT_EQ(0U, resource_list->entries().size()); | 312 EXPECT_EQ(0U, resource_list->entries().size()); |
313 // It's considered loaded even if the result is empty. | 313 // It's considered loaded even if the result is empty. |
314 EXPECT_EQ(1, fake_service_.resource_list_load_count()); | 314 EXPECT_EQ(1, fake_service_.resource_list_load_count()); |
315 } | 315 } |
316 | 316 |
317 TEST_F(FakeDriveServiceTest, GetResourceList_WithNewEntry) { | 317 TEST_F(FakeDriveServiceTest, GetResourceList_WithNewEntry) { |
318 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 318 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( |
319 "chromeos/gdata/root_feed.json")); | 319 "chromeos/gdata/root_feed.json")); |
320 // Load the account_metadata.json as well to add the largest changestamp | 320 // Load the account_metadata.json as well to add the largest changestamp |
321 // (654321) to the existing entries. | 321 // (654321) to the existing entries. |
322 ASSERT_TRUE(fake_service_.LoadAccountMetadataForWapi( | 322 ASSERT_TRUE(fake_service_.LoadAccountMetadataForWapi( |
323 "chromeos/gdata/account_metadata.json")); | 323 "chromeos/gdata/account_metadata.json")); |
324 // Add a new directory in the root directory. The new directory will have | 324 // Add a new directory in the root directory. The new directory will have |
325 // the changestamp of 654322. | 325 // the changestamp of 654322. |
326 ASSERT_TRUE(AddNewDirectory( | 326 ASSERT_TRUE(AddNewDirectory( |
327 fake_service_.GetRootResourceId(), "new directory")); | 327 fake_service_.GetRootResourceId(), "new directory")); |
328 | 328 |
329 // Get the resource list newer than 654321. | 329 // Get the resource list newer than 654321. |
330 GDataErrorCode error = GDATA_OTHER_ERROR; | 330 GDataErrorCode error = GDATA_OTHER_ERROR; |
331 scoped_ptr<ResourceList> resource_list; | 331 scoped_ptr<ResourceList> resource_list; |
332 fake_service_.GetResourceList( | 332 fake_service_.GetResourceList( |
333 GURL(), | 333 GURL(), |
334 654321 + 1, // start_changestamp | 334 654321 + 1, // start_changestamp |
335 "", // search_query | 335 std::string(), // search_query |
336 "", // directory_resource_id | 336 std::string(), // directory_resource_id |
337 test_util::CreateCopyResultCallback(&error, &resource_list)); | 337 test_util::CreateCopyResultCallback(&error, &resource_list)); |
338 message_loop_.RunUntilIdle(); | 338 message_loop_.RunUntilIdle(); |
339 | 339 |
340 EXPECT_EQ(HTTP_SUCCESS, error); | 340 EXPECT_EQ(HTTP_SUCCESS, error); |
341 ASSERT_TRUE(resource_list); | 341 ASSERT_TRUE(resource_list); |
342 // The result should only contain the newly created directory. | 342 // The result should only contain the newly created directory. |
343 ASSERT_EQ(1U, resource_list->entries().size()); | 343 ASSERT_EQ(1U, resource_list->entries().size()); |
344 EXPECT_EQ("new directory", resource_list->entries()[0]->title()); | 344 EXPECT_EQ("new directory", resource_list->entries()[0]->title()); |
345 EXPECT_EQ(1, fake_service_.resource_list_load_count()); | 345 EXPECT_EQ(1, fake_service_.resource_list_load_count()); |
346 } | 346 } |
347 | 347 |
348 TEST_F(FakeDriveServiceTest, GetResourceList_Offline) { | 348 TEST_F(FakeDriveServiceTest, GetResourceList_Offline) { |
349 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 349 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( |
350 "chromeos/gdata/root_feed.json")); | 350 "chromeos/gdata/root_feed.json")); |
351 fake_service_.set_offline(true); | 351 fake_service_.set_offline(true); |
352 | 352 |
353 GDataErrorCode error = GDATA_OTHER_ERROR; | 353 GDataErrorCode error = GDATA_OTHER_ERROR; |
354 scoped_ptr<ResourceList> resource_list; | 354 scoped_ptr<ResourceList> resource_list; |
355 fake_service_.GetResourceList( | 355 fake_service_.GetResourceList( |
356 GURL(), | 356 GURL(), |
357 0, // start_changestamp | 357 0, // start_changestamp |
358 "", // search_query | 358 std::string(), // search_query |
359 "", // directory_resource_id | 359 std::string(), // directory_resource_id |
360 test_util::CreateCopyResultCallback(&error, &resource_list)); | 360 test_util::CreateCopyResultCallback(&error, &resource_list)); |
361 message_loop_.RunUntilIdle(); | 361 message_loop_.RunUntilIdle(); |
362 | 362 |
363 EXPECT_EQ(GDATA_NO_CONNECTION, error); | 363 EXPECT_EQ(GDATA_NO_CONNECTION, error); |
364 EXPECT_FALSE(resource_list); | 364 EXPECT_FALSE(resource_list); |
365 } | 365 } |
366 | 366 |
367 TEST_F(FakeDriveServiceTest, GetAllResourceList) { | 367 TEST_F(FakeDriveServiceTest, GetAllResourceList) { |
368 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 368 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( |
369 "chromeos/gdata/root_feed.json")); | 369 "chromeos/gdata/root_feed.json")); |
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
838 | 838 |
839 TEST_F(FakeDriveServiceTest, DeleteResource_ExistingFile) { | 839 TEST_F(FakeDriveServiceTest, DeleteResource_ExistingFile) { |
840 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 840 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( |
841 "chromeos/gdata/root_feed.json")); | 841 "chromeos/gdata/root_feed.json")); |
842 | 842 |
843 // Resource "file:2_file_resource_id" should now exist. | 843 // Resource "file:2_file_resource_id" should now exist. |
844 ASSERT_TRUE(Exists("file:2_file_resource_id")); | 844 ASSERT_TRUE(Exists("file:2_file_resource_id")); |
845 | 845 |
846 GDataErrorCode error = GDATA_OTHER_ERROR; | 846 GDataErrorCode error = GDATA_OTHER_ERROR; |
847 fake_service_.DeleteResource("file:2_file_resource_id", | 847 fake_service_.DeleteResource("file:2_file_resource_id", |
848 "", // etag | 848 std::string(), // etag |
849 test_util::CreateCopyResultCallback(&error)); | 849 test_util::CreateCopyResultCallback(&error)); |
850 message_loop_.RunUntilIdle(); | 850 message_loop_.RunUntilIdle(); |
851 | 851 |
852 EXPECT_EQ(HTTP_SUCCESS, error); | 852 EXPECT_EQ(HTTP_SUCCESS, error); |
853 // Resource "file:2_file_resource_id" should be gone now. | 853 // Resource "file:2_file_resource_id" should be gone now. |
854 EXPECT_FALSE(Exists("file:2_file_resource_id")); | 854 EXPECT_FALSE(Exists("file:2_file_resource_id")); |
855 } | 855 } |
856 | 856 |
857 TEST_F(FakeDriveServiceTest, DeleteResource_NonexistingFile) { | 857 TEST_F(FakeDriveServiceTest, DeleteResource_NonexistingFile) { |
858 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 858 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( |
859 "chromeos/gdata/root_feed.json")); | 859 "chromeos/gdata/root_feed.json")); |
860 | 860 |
861 GDataErrorCode error = GDATA_OTHER_ERROR; | 861 GDataErrorCode error = GDATA_OTHER_ERROR; |
862 fake_service_.DeleteResource("file:nonexisting_resource_id", | 862 fake_service_.DeleteResource("file:nonexisting_resource_id", |
863 "", // etag | 863 std::string(), // etag |
864 test_util::CreateCopyResultCallback(&error)); | 864 test_util::CreateCopyResultCallback(&error)); |
865 message_loop_.RunUntilIdle(); | 865 message_loop_.RunUntilIdle(); |
866 | 866 |
867 EXPECT_EQ(HTTP_NOT_FOUND, error); | 867 EXPECT_EQ(HTTP_NOT_FOUND, error); |
868 } | 868 } |
869 | 869 |
870 TEST_F(FakeDriveServiceTest, DeleteResource_Offline) { | 870 TEST_F(FakeDriveServiceTest, DeleteResource_Offline) { |
871 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 871 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( |
872 "chromeos/gdata/root_feed.json")); | 872 "chromeos/gdata/root_feed.json")); |
873 fake_service_.set_offline(true); | 873 fake_service_.set_offline(true); |
874 | 874 |
875 GDataErrorCode error = GDATA_OTHER_ERROR; | 875 GDataErrorCode error = GDATA_OTHER_ERROR; |
876 fake_service_.DeleteResource("file:2_file_resource_id", | 876 fake_service_.DeleteResource("file:2_file_resource_id", |
877 "", // etag | 877 std::string(), // etag |
878 test_util::CreateCopyResultCallback(&error)); | 878 test_util::CreateCopyResultCallback(&error)); |
879 message_loop_.RunUntilIdle(); | 879 message_loop_.RunUntilIdle(); |
880 | 880 |
881 EXPECT_EQ(GDATA_NO_CONNECTION, error); | 881 EXPECT_EQ(GDATA_NO_CONNECTION, error); |
882 } | 882 } |
883 | 883 |
884 TEST_F(FakeDriveServiceTest, DownloadFile_ExistingFile) { | 884 TEST_F(FakeDriveServiceTest, DownloadFile_ExistingFile) { |
885 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 885 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( |
886 "chromeos/gdata/root_feed.json")); | 886 "chromeos/gdata/root_feed.json")); |
887 | 887 |
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1499 "chromeos/gdata/root_feed.json")); | 1499 "chromeos/gdata/root_feed.json")); |
1500 fake_service_.set_offline(true); | 1500 fake_service_.set_offline(true); |
1501 | 1501 |
1502 GDataErrorCode error = GDATA_OTHER_ERROR; | 1502 GDataErrorCode error = GDATA_OTHER_ERROR; |
1503 GURL upload_location; | 1503 GURL upload_location; |
1504 fake_service_.InitiateUploadExistingFile( | 1504 fake_service_.InitiateUploadExistingFile( |
1505 base::FilePath(FILE_PATH_LITERAL("drive/File 1")), | 1505 base::FilePath(FILE_PATH_LITERAL("drive/File 1")), |
1506 "test/foo", | 1506 "test/foo", |
1507 13, | 1507 13, |
1508 "file:2_file_resource_id", | 1508 "file:2_file_resource_id", |
1509 "", // etag | 1509 std::string(), // etag |
1510 test_util::CreateCopyResultCallback(&error, &upload_location)); | 1510 test_util::CreateCopyResultCallback(&error, &upload_location)); |
1511 message_loop_.RunUntilIdle(); | 1511 message_loop_.RunUntilIdle(); |
1512 | 1512 |
1513 EXPECT_EQ(GDATA_NO_CONNECTION, error); | 1513 EXPECT_EQ(GDATA_NO_CONNECTION, error); |
1514 EXPECT_TRUE(upload_location.is_empty()); | 1514 EXPECT_TRUE(upload_location.is_empty()); |
1515 } | 1515 } |
1516 | 1516 |
1517 TEST_F(FakeDriveServiceTest, InitiateUploadExistingFile_NotFound) { | 1517 TEST_F(FakeDriveServiceTest, InitiateUploadExistingFile_NotFound) { |
1518 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 1518 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( |
1519 "chromeos/gdata/root_feed.json")); | 1519 "chromeos/gdata/root_feed.json")); |
1520 | 1520 |
1521 GDataErrorCode error = GDATA_OTHER_ERROR; | 1521 GDataErrorCode error = GDATA_OTHER_ERROR; |
1522 GURL upload_location; | 1522 GURL upload_location; |
1523 fake_service_.InitiateUploadExistingFile( | 1523 fake_service_.InitiateUploadExistingFile( |
1524 base::FilePath(FILE_PATH_LITERAL("drive/File 1")), | 1524 base::FilePath(FILE_PATH_LITERAL("drive/File 1")), |
1525 "test/foo", | 1525 "test/foo", |
1526 13, | 1526 13, |
1527 "non_existent", | 1527 "non_existent", |
1528 "", // etag | 1528 std::string(), // etag |
1529 test_util::CreateCopyResultCallback(&error, &upload_location)); | 1529 test_util::CreateCopyResultCallback(&error, &upload_location)); |
1530 message_loop_.RunUntilIdle(); | 1530 message_loop_.RunUntilIdle(); |
1531 | 1531 |
1532 EXPECT_EQ(HTTP_NOT_FOUND, error); | 1532 EXPECT_EQ(HTTP_NOT_FOUND, error); |
1533 EXPECT_TRUE(upload_location.is_empty()); | 1533 EXPECT_TRUE(upload_location.is_empty()); |
1534 } | 1534 } |
1535 | 1535 |
1536 TEST_F(FakeDriveServiceTest, InitiateUploadExistingFile_WrongETag) { | 1536 TEST_F(FakeDriveServiceTest, InitiateUploadExistingFile_WrongETag) { |
1537 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( | 1537 ASSERT_TRUE(fake_service_.LoadResourceListForWapi( |
1538 "chromeos/gdata/root_feed.json")); | 1538 "chromeos/gdata/root_feed.json")); |
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1948 test_util::CreateCopyResultCallback(&error, &resource_entry)); | 1948 test_util::CreateCopyResultCallback(&error, &resource_entry)); |
1949 message_loop_.RunUntilIdle(); | 1949 message_loop_.RunUntilIdle(); |
1950 | 1950 |
1951 EXPECT_EQ(GDATA_NO_CONNECTION, error); | 1951 EXPECT_EQ(GDATA_NO_CONNECTION, error); |
1952 EXPECT_FALSE(resource_entry); | 1952 EXPECT_FALSE(resource_entry); |
1953 } | 1953 } |
1954 | 1954 |
1955 } // namespace | 1955 } // namespace |
1956 | 1956 |
1957 } // namespace google_apis | 1957 } // namespace google_apis |
OLD | NEW |