Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: chrome/browser/chromeos/drive/job_scheduler_unittest.cc

Issue 318873003: drive: Stop returning ResourceList from JobScheduler (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/chromeos/drive/job_scheduler.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/chromeos/drive/job_scheduler.h" 5 #include "chrome/browser/chromeos/drive/job_scheduler.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 scoped_ptr<google_apis::AppList> app_list; 210 scoped_ptr<google_apis::AppList> app_list;
211 211
212 scheduler_->GetAppList( 212 scheduler_->GetAppList(
213 google_apis::test_util::CreateCopyResultCallback(&error, &app_list)); 213 google_apis::test_util::CreateCopyResultCallback(&error, &app_list));
214 base::RunLoop().RunUntilIdle(); 214 base::RunLoop().RunUntilIdle();
215 215
216 ASSERT_EQ(google_apis::HTTP_SUCCESS, error); 216 ASSERT_EQ(google_apis::HTTP_SUCCESS, error);
217 ASSERT_TRUE(app_list); 217 ASSERT_TRUE(app_list);
218 } 218 }
219 219
220 TEST_F(JobSchedulerTest, GetAllResourceList) { 220 TEST_F(JobSchedulerTest, GetAllFileList) {
221 ConnectToWifi(); 221 ConnectToWifi();
222 222
223 google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR; 223 google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR;
224 scoped_ptr<google_apis::ResourceList> resource_list; 224 scoped_ptr<google_apis::FileList> file_list;
225 225
226 scheduler_->GetAllResourceList( 226 scheduler_->GetAllFileList(
227 google_apis::test_util::CreateCopyResultCallback( 227 google_apis::test_util::CreateCopyResultCallback(&error, &file_list));
228 &error, &resource_list));
229 base::RunLoop().RunUntilIdle(); 228 base::RunLoop().RunUntilIdle();
230 229
231 ASSERT_EQ(google_apis::HTTP_SUCCESS, error); 230 ASSERT_EQ(google_apis::HTTP_SUCCESS, error);
232 ASSERT_TRUE(resource_list); 231 ASSERT_TRUE(file_list);
233 } 232 }
234 233
235 TEST_F(JobSchedulerTest, GetResourceListInDirectory) { 234 TEST_F(JobSchedulerTest, GetFileListInDirectory) {
236 ConnectToWifi(); 235 ConnectToWifi();
237 236
238 google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR; 237 google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR;
239 scoped_ptr<google_apis::ResourceList> resource_list; 238 scoped_ptr<google_apis::FileList> file_list;
240 239
241 scheduler_->GetResourceListInDirectory( 240 scheduler_->GetFileListInDirectory(
242 fake_drive_service_->GetRootResourceId(), 241 fake_drive_service_->GetRootResourceId(),
243 google_apis::test_util::CreateCopyResultCallback( 242 google_apis::test_util::CreateCopyResultCallback(&error, &file_list));
244 &error, &resource_list));
245 base::RunLoop().RunUntilIdle(); 243 base::RunLoop().RunUntilIdle();
246 244
247 ASSERT_EQ(google_apis::HTTP_SUCCESS, error); 245 ASSERT_EQ(google_apis::HTTP_SUCCESS, error);
248 ASSERT_TRUE(resource_list); 246 ASSERT_TRUE(file_list);
249 } 247 }
250 248
251 TEST_F(JobSchedulerTest, Search) { 249 TEST_F(JobSchedulerTest, Search) {
252 ConnectToWifi(); 250 ConnectToWifi();
253 251
254 google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR; 252 google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR;
255 scoped_ptr<google_apis::ResourceList> resource_list; 253 scoped_ptr<google_apis::FileList> file_list;
256 254
257 scheduler_->Search( 255 scheduler_->Search(
258 "File", // search query 256 "File", // search query
259 google_apis::test_util::CreateCopyResultCallback( 257 google_apis::test_util::CreateCopyResultCallback(&error, &file_list));
260 &error, &resource_list));
261 base::RunLoop().RunUntilIdle(); 258 base::RunLoop().RunUntilIdle();
262 259
263 ASSERT_EQ(google_apis::HTTP_SUCCESS, error); 260 ASSERT_EQ(google_apis::HTTP_SUCCESS, error);
264 ASSERT_TRUE(resource_list); 261 ASSERT_TRUE(file_list);
265 } 262 }
266 263
267 TEST_F(JobSchedulerTest, GetChangeList) { 264 TEST_F(JobSchedulerTest, GetChangeList) {
268 ConnectToWifi(); 265 ConnectToWifi();
269 266
270 int64 old_largest_change_id = 267 int64 old_largest_change_id =
271 fake_drive_service_->about_resource().largest_change_id(); 268 fake_drive_service_->about_resource().largest_change_id();
272 269
273 google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR; 270 google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR;
274 271
275 // Create a new directory. 272 // Create a new directory.
276 { 273 {
277 scoped_ptr<google_apis::FileResource> entry; 274 scoped_ptr<google_apis::FileResource> entry;
278 fake_drive_service_->AddNewDirectory( 275 fake_drive_service_->AddNewDirectory(
279 fake_drive_service_->GetRootResourceId(), 276 fake_drive_service_->GetRootResourceId(),
280 "new directory", 277 "new directory",
281 DriveServiceInterface::AddNewDirectoryOptions(), 278 DriveServiceInterface::AddNewDirectoryOptions(),
282 google_apis::test_util::CreateCopyResultCallback( 279 google_apis::test_util::CreateCopyResultCallback(
283 &error, &entry)); 280 &error, &entry));
284 base::RunLoop().RunUntilIdle(); 281 base::RunLoop().RunUntilIdle();
285 ASSERT_EQ(google_apis::HTTP_CREATED, error); 282 ASSERT_EQ(google_apis::HTTP_CREATED, error);
286 } 283 }
287 284
288 error = google_apis::GDATA_OTHER_ERROR; 285 error = google_apis::GDATA_OTHER_ERROR;
289 scoped_ptr<google_apis::ResourceList> resource_list; 286 scoped_ptr<google_apis::ChangeList> change_list;
290 scheduler_->GetChangeList( 287 scheduler_->GetChangeList(
291 old_largest_change_id + 1, 288 old_largest_change_id + 1,
292 google_apis::test_util::CreateCopyResultCallback( 289 google_apis::test_util::CreateCopyResultCallback(&error, &change_list));
293 &error, &resource_list));
294 base::RunLoop().RunUntilIdle(); 290 base::RunLoop().RunUntilIdle();
295 291
296 ASSERT_EQ(google_apis::HTTP_SUCCESS, error); 292 ASSERT_EQ(google_apis::HTTP_SUCCESS, error);
297 ASSERT_TRUE(resource_list); 293 ASSERT_TRUE(change_list);
298 } 294 }
299 295
300 TEST_F(JobSchedulerTest, GetRemainingChangeList) { 296 TEST_F(JobSchedulerTest, GetRemainingChangeList) {
301 ConnectToWifi(); 297 ConnectToWifi();
302 fake_drive_service_->set_default_max_results(2); 298 fake_drive_service_->set_default_max_results(2);
303 299
304 google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR; 300 google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR;
305 scoped_ptr<google_apis::ResourceList> resource_list; 301 scoped_ptr<google_apis::ChangeList> change_list;
306 302
307 scheduler_->GetAllResourceList( 303 scheduler_->GetChangeList(
308 google_apis::test_util::CreateCopyResultCallback( 304 0,
309 &error, &resource_list)); 305 google_apis::test_util::CreateCopyResultCallback(&error, &change_list));
310 base::RunLoop().RunUntilIdle(); 306 base::RunLoop().RunUntilIdle();
311 307
312 ASSERT_EQ(google_apis::HTTP_SUCCESS, error); 308 ASSERT_EQ(google_apis::HTTP_SUCCESS, error);
313 ASSERT_TRUE(resource_list); 309 ASSERT_TRUE(change_list);
314 310
315 const google_apis::Link* next_link = 311 // Keep the next url before releasing the |change_list|.
316 resource_list->GetLinkByType(google_apis::Link::LINK_NEXT); 312 GURL next_url(change_list->next_link());
317 ASSERT_TRUE(next_link);
318 // Keep the next url before releasing the |resource_list|.
319 GURL next_url(next_link->href());
320 313
321 error = google_apis::GDATA_OTHER_ERROR; 314 error = google_apis::GDATA_OTHER_ERROR;
322 resource_list.reset(); 315 change_list.reset();
323 316
324 scheduler_->GetRemainingChangeList( 317 scheduler_->GetRemainingChangeList(
325 next_url, 318 next_url,
326 google_apis::test_util::CreateCopyResultCallback( 319 google_apis::test_util::CreateCopyResultCallback(&error, &change_list));
327 &error, &resource_list));
328 base::RunLoop().RunUntilIdle(); 320 base::RunLoop().RunUntilIdle();
329 321
330 ASSERT_EQ(google_apis::HTTP_SUCCESS, error); 322 ASSERT_EQ(google_apis::HTTP_SUCCESS, error);
331 ASSERT_TRUE(resource_list); 323 ASSERT_TRUE(change_list);
332 } 324 }
333 325
334 TEST_F(JobSchedulerTest, GetRemainingFileList) { 326 TEST_F(JobSchedulerTest, GetRemainingFileList) {
335 ConnectToWifi(); 327 ConnectToWifi();
336 fake_drive_service_->set_default_max_results(2); 328 fake_drive_service_->set_default_max_results(2);
337 329
338 google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR; 330 google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR;
339 scoped_ptr<google_apis::ResourceList> resource_list; 331 scoped_ptr<google_apis::FileList> file_list;
340 332
341 scheduler_->GetResourceListInDirectory( 333 scheduler_->GetFileListInDirectory(
342 fake_drive_service_->GetRootResourceId(), 334 fake_drive_service_->GetRootResourceId(),
343 google_apis::test_util::CreateCopyResultCallback( 335 google_apis::test_util::CreateCopyResultCallback(&error, &file_list));
344 &error, &resource_list));
345 base::RunLoop().RunUntilIdle(); 336 base::RunLoop().RunUntilIdle();
346 337
347 ASSERT_EQ(google_apis::HTTP_SUCCESS, error); 338 ASSERT_EQ(google_apis::HTTP_SUCCESS, error);
348 ASSERT_TRUE(resource_list); 339 ASSERT_TRUE(file_list);
349 340
350 const google_apis::Link* next_link = 341 // Keep the next url before releasing the |file_list|.
351 resource_list->GetLinkByType(google_apis::Link::LINK_NEXT); 342 GURL next_url(file_list->next_link());
352 ASSERT_TRUE(next_link);
353 // Keep the next url before releasing the |resource_list|.
354 GURL next_url(next_link->href());
355 343
356 error = google_apis::GDATA_OTHER_ERROR; 344 error = google_apis::GDATA_OTHER_ERROR;
357 resource_list.reset(); 345 file_list.reset();
358 346
359 scheduler_->GetRemainingFileList( 347 scheduler_->GetRemainingFileList(
360 next_url, 348 next_url,
361 google_apis::test_util::CreateCopyResultCallback( 349 google_apis::test_util::CreateCopyResultCallback(&error, &file_list));
362 &error, &resource_list));
363 base::RunLoop().RunUntilIdle(); 350 base::RunLoop().RunUntilIdle();
364 351
365 ASSERT_EQ(google_apis::HTTP_SUCCESS, error); 352 ASSERT_EQ(google_apis::HTTP_SUCCESS, error);
366 ASSERT_TRUE(resource_list); 353 ASSERT_TRUE(file_list);
367 } 354 }
368 355
369 TEST_F(JobSchedulerTest, GetResourceEntry) { 356 TEST_F(JobSchedulerTest, GetResourceEntry) {
370 ConnectToWifi(); 357 ConnectToWifi();
371 358
372 google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR; 359 google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR;
373 scoped_ptr<google_apis::ResourceEntry> entry; 360 scoped_ptr<google_apis::ResourceEntry> entry;
374 361
375 scheduler_->GetResourceEntry( 362 scheduler_->GetResourceEntry(
376 "file:2_file_resource_id", // resource ID 363 "file:2_file_resource_id", // resource ID
(...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after
1075 scheduler_->CancelJob(first_job_id); 1062 scheduler_->CancelJob(first_job_id);
1076 1063
1077 // Only the first job should be cancelled. 1064 // Only the first job should be cancelled.
1078 base::RunLoop().RunUntilIdle(); 1065 base::RunLoop().RunUntilIdle();
1079 EXPECT_EQ(google_apis::GDATA_CANCELLED, error1); 1066 EXPECT_EQ(google_apis::GDATA_CANCELLED, error1);
1080 EXPECT_EQ(google_apis::HTTP_SUCCESS, error2); 1067 EXPECT_EQ(google_apis::HTTP_SUCCESS, error2);
1081 EXPECT_TRUE(scheduler_->GetJobInfoList().empty()); 1068 EXPECT_TRUE(scheduler_->GetJobInfoList().empty());
1082 } 1069 }
1083 1070
1084 } // namespace drive 1071 } // namespace drive
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/drive/job_scheduler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698