| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/files/file_path.h" | 6 #include "base/files/file_path.h" |
| 7 #include "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 "Range", "bytes=0-" + base::Int64ToString(received_bytes_ - 1)); | 266 "Range", "bytes=0-" + base::Int64ToString(received_bytes_ - 1)); |
| 267 } | 267 } |
| 268 | 268 |
| 269 return response.PassAs<net::test_server::HttpResponse>(); | 269 return response.PassAs<net::test_server::HttpResponse>(); |
| 270 } | 270 } |
| 271 | 271 |
| 272 // All bytes are received. Return the "success" response with the file's | 272 // All bytes are received. Return the "success" response with the file's |
| 273 // (dummy) metadata. | 273 // (dummy) metadata. |
| 274 scoped_ptr<net::test_server::BasicHttpResponse> response = | 274 scoped_ptr<net::test_server::BasicHttpResponse> response = |
| 275 test_util::CreateHttpResponseFromFile( | 275 test_util::CreateHttpResponseFromFile( |
| 276 test_util::GetTestFilePath("chromeos/drive/file_entry.json")); | 276 test_util::GetTestFilePath("drive/file_entry.json")); |
| 277 | 277 |
| 278 // The response code is CREATED if it is new file uploading. | 278 // The response code is CREATED if it is new file uploading. |
| 279 if (http_request_.relative_url == kTestUploadNewFilePath) { | 279 if (http_request_.relative_url == kTestUploadNewFilePath) { |
| 280 response->set_code(net::HTTP_CREATED); | 280 response->set_code(net::HTTP_CREATED); |
| 281 } | 281 } |
| 282 | 282 |
| 283 return response.PassAs<net::test_server::HttpResponse>(); | 283 return response.PassAs<net::test_server::HttpResponse>(); |
| 284 } | 284 } |
| 285 | 285 |
| 286 // Returns the response based on set expected content and its type. | 286 // Returns the response based on set expected content and its type. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 305 } | 305 } |
| 306 | 306 |
| 307 // These are for the current upload file status. | 307 // These are for the current upload file status. |
| 308 int64 received_bytes_; | 308 int64 received_bytes_; |
| 309 int64 content_length_; | 309 int64 content_length_; |
| 310 }; | 310 }; |
| 311 | 311 |
| 312 TEST_F(DriveApiRequestsTest, GetAboutRequest_ValidJson) { | 312 TEST_F(DriveApiRequestsTest, GetAboutRequest_ValidJson) { |
| 313 // Set an expected data file containing valid result. | 313 // Set an expected data file containing valid result. |
| 314 expected_data_file_path_ = test_util::GetTestFilePath( | 314 expected_data_file_path_ = test_util::GetTestFilePath( |
| 315 "chromeos/drive/about.json"); | 315 "drive/about.json"); |
| 316 | 316 |
| 317 GDataErrorCode error = GDATA_OTHER_ERROR; | 317 GDataErrorCode error = GDATA_OTHER_ERROR; |
| 318 scoped_ptr<AboutResource> about_resource; | 318 scoped_ptr<AboutResource> about_resource; |
| 319 | 319 |
| 320 { | 320 { |
| 321 base::RunLoop run_loop; | 321 base::RunLoop run_loop; |
| 322 GetAboutRequest* request = new GetAboutRequest( | 322 GetAboutRequest* request = new GetAboutRequest( |
| 323 request_sender_.get(), | 323 request_sender_.get(), |
| 324 *url_generator_, | 324 *url_generator_, |
| 325 test_util::CreateQuitCallback( | 325 test_util::CreateQuitCallback( |
| 326 &run_loop, | 326 &run_loop, |
| 327 test_util::CreateCopyResultCallback(&error, &about_resource))); | 327 test_util::CreateCopyResultCallback(&error, &about_resource))); |
| 328 request_sender_->StartRequestWithRetry(request); | 328 request_sender_->StartRequestWithRetry(request); |
| 329 run_loop.Run(); | 329 run_loop.Run(); |
| 330 } | 330 } |
| 331 | 331 |
| 332 EXPECT_EQ(HTTP_SUCCESS, error); | 332 EXPECT_EQ(HTTP_SUCCESS, error); |
| 333 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); | 333 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); |
| 334 EXPECT_EQ("/drive/v2/about", http_request_.relative_url); | 334 EXPECT_EQ("/drive/v2/about", http_request_.relative_url); |
| 335 | 335 |
| 336 scoped_ptr<AboutResource> expected( | 336 scoped_ptr<AboutResource> expected( |
| 337 AboutResource::CreateFrom( | 337 AboutResource::CreateFrom( |
| 338 *test_util::LoadJSONFile("chromeos/drive/about.json"))); | 338 *test_util::LoadJSONFile("drive/about.json"))); |
| 339 ASSERT_TRUE(about_resource.get()); | 339 ASSERT_TRUE(about_resource.get()); |
| 340 EXPECT_EQ(expected->largest_change_id(), about_resource->largest_change_id()); | 340 EXPECT_EQ(expected->largest_change_id(), about_resource->largest_change_id()); |
| 341 EXPECT_EQ(expected->quota_bytes_total(), about_resource->quota_bytes_total()); | 341 EXPECT_EQ(expected->quota_bytes_total(), about_resource->quota_bytes_total()); |
| 342 EXPECT_EQ(expected->quota_bytes_used(), about_resource->quota_bytes_used()); | 342 EXPECT_EQ(expected->quota_bytes_used(), about_resource->quota_bytes_used()); |
| 343 EXPECT_EQ(expected->root_folder_id(), about_resource->root_folder_id()); | 343 EXPECT_EQ(expected->root_folder_id(), about_resource->root_folder_id()); |
| 344 } | 344 } |
| 345 | 345 |
| 346 TEST_F(DriveApiRequestsTest, GetAboutRequest_InvalidJson) { | 346 TEST_F(DriveApiRequestsTest, GetAboutRequest_InvalidJson) { |
| 347 // Set an expected data file containing invalid result. | 347 // Set an expected data file containing invalid result. |
| 348 expected_data_file_path_ = test_util::GetTestFilePath( | 348 expected_data_file_path_ = test_util::GetTestFilePath( |
| 349 "chromeos/gdata/testfile.txt"); | 349 "gdata/testfile.txt"); |
| 350 | 350 |
| 351 GDataErrorCode error = GDATA_OTHER_ERROR; | 351 GDataErrorCode error = GDATA_OTHER_ERROR; |
| 352 scoped_ptr<AboutResource> about_resource; | 352 scoped_ptr<AboutResource> about_resource; |
| 353 | 353 |
| 354 { | 354 { |
| 355 base::RunLoop run_loop; | 355 base::RunLoop run_loop; |
| 356 GetAboutRequest* request = new GetAboutRequest( | 356 GetAboutRequest* request = new GetAboutRequest( |
| 357 request_sender_.get(), | 357 request_sender_.get(), |
| 358 *url_generator_, | 358 *url_generator_, |
| 359 test_util::CreateQuitCallback( | 359 test_util::CreateQuitCallback( |
| 360 &run_loop, | 360 &run_loop, |
| 361 test_util::CreateCopyResultCallback(&error, &about_resource))); | 361 test_util::CreateCopyResultCallback(&error, &about_resource))); |
| 362 request_sender_->StartRequestWithRetry(request); | 362 request_sender_->StartRequestWithRetry(request); |
| 363 run_loop.Run(); | 363 run_loop.Run(); |
| 364 } | 364 } |
| 365 | 365 |
| 366 // "parse error" should be returned, and the about resource should be NULL. | 366 // "parse error" should be returned, and the about resource should be NULL. |
| 367 EXPECT_EQ(GDATA_PARSE_ERROR, error); | 367 EXPECT_EQ(GDATA_PARSE_ERROR, error); |
| 368 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); | 368 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); |
| 369 EXPECT_EQ("/drive/v2/about", http_request_.relative_url); | 369 EXPECT_EQ("/drive/v2/about", http_request_.relative_url); |
| 370 EXPECT_FALSE(about_resource.get()); | 370 EXPECT_FALSE(about_resource.get()); |
| 371 } | 371 } |
| 372 | 372 |
| 373 TEST_F(DriveApiRequestsTest, GetApplistRequest) { | 373 TEST_F(DriveApiRequestsTest, GetApplistRequest) { |
| 374 // Set an expected data file containing valid result. | 374 // Set an expected data file containing valid result. |
| 375 expected_data_file_path_ = test_util::GetTestFilePath( | 375 expected_data_file_path_ = test_util::GetTestFilePath( |
| 376 "chromeos/drive/applist.json"); | 376 "drive/applist.json"); |
| 377 | 377 |
| 378 GDataErrorCode error = GDATA_OTHER_ERROR; | 378 GDataErrorCode error = GDATA_OTHER_ERROR; |
| 379 scoped_ptr<base::Value> result; | 379 scoped_ptr<base::Value> result; |
| 380 | 380 |
| 381 { | 381 { |
| 382 base::RunLoop run_loop; | 382 base::RunLoop run_loop; |
| 383 GetApplistRequest* request = new GetApplistRequest( | 383 GetApplistRequest* request = new GetApplistRequest( |
| 384 request_sender_.get(), | 384 request_sender_.get(), |
| 385 *url_generator_, | 385 *url_generator_, |
| 386 test_util::CreateQuitCallback( | 386 test_util::CreateQuitCallback( |
| 387 &run_loop, | 387 &run_loop, |
| 388 test_util::CreateCopyResultCallback(&error, &result))); | 388 test_util::CreateCopyResultCallback(&error, &result))); |
| 389 request_sender_->StartRequestWithRetry(request); | 389 request_sender_->StartRequestWithRetry(request); |
| 390 run_loop.Run(); | 390 run_loop.Run(); |
| 391 } | 391 } |
| 392 | 392 |
| 393 EXPECT_EQ(HTTP_SUCCESS, error); | 393 EXPECT_EQ(HTTP_SUCCESS, error); |
| 394 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); | 394 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); |
| 395 EXPECT_EQ("/drive/v2/apps", http_request_.relative_url); | 395 EXPECT_EQ("/drive/v2/apps", http_request_.relative_url); |
| 396 EXPECT_TRUE(result); | 396 EXPECT_TRUE(result); |
| 397 } | 397 } |
| 398 | 398 |
| 399 TEST_F(DriveApiRequestsTest, GetChangelistRequest) { | 399 TEST_F(DriveApiRequestsTest, GetChangelistRequest) { |
| 400 // Set an expected data file containing valid result. | 400 // Set an expected data file containing valid result. |
| 401 expected_data_file_path_ = test_util::GetTestFilePath( | 401 expected_data_file_path_ = test_util::GetTestFilePath( |
| 402 "chromeos/drive/changelist.json"); | 402 "drive/changelist.json"); |
| 403 | 403 |
| 404 GDataErrorCode error = GDATA_OTHER_ERROR; | 404 GDataErrorCode error = GDATA_OTHER_ERROR; |
| 405 scoped_ptr<base::Value> result; | 405 scoped_ptr<base::Value> result; |
| 406 | 406 |
| 407 { | 407 { |
| 408 base::RunLoop run_loop; | 408 base::RunLoop run_loop; |
| 409 GetChangelistRequest* request = new GetChangelistRequest( | 409 GetChangelistRequest* request = new GetChangelistRequest( |
| 410 request_sender_.get(), | 410 request_sender_.get(), |
| 411 *url_generator_, | 411 *url_generator_, |
| 412 true, // include deleted | 412 true, // include deleted |
| 413 100, // start changestamp | 413 100, // start changestamp |
| 414 500, // max results | 414 500, // max results |
| 415 test_util::CreateQuitCallback( | 415 test_util::CreateQuitCallback( |
| 416 &run_loop, | 416 &run_loop, |
| 417 test_util::CreateCopyResultCallback(&error, &result))); | 417 test_util::CreateCopyResultCallback(&error, &result))); |
| 418 request_sender_->StartRequestWithRetry(request); | 418 request_sender_->StartRequestWithRetry(request); |
| 419 run_loop.Run(); | 419 run_loop.Run(); |
| 420 } | 420 } |
| 421 | 421 |
| 422 EXPECT_EQ(HTTP_SUCCESS, error); | 422 EXPECT_EQ(HTTP_SUCCESS, error); |
| 423 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); | 423 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); |
| 424 EXPECT_EQ("/drive/v2/changes?startChangeId=100&maxResults=500", | 424 EXPECT_EQ("/drive/v2/changes?startChangeId=100&maxResults=500", |
| 425 http_request_.relative_url); | 425 http_request_.relative_url); |
| 426 EXPECT_TRUE(result); | 426 EXPECT_TRUE(result); |
| 427 } | 427 } |
| 428 | 428 |
| 429 TEST_F(DriveApiRequestsTest, GetFilelistRequest) { | 429 TEST_F(DriveApiRequestsTest, GetFilelistRequest) { |
| 430 // Set an expected data file containing valid result. | 430 // Set an expected data file containing valid result. |
| 431 expected_data_file_path_ = test_util::GetTestFilePath( | 431 expected_data_file_path_ = test_util::GetTestFilePath( |
| 432 "chromeos/drive/filelist.json"); | 432 "drive/filelist.json"); |
| 433 | 433 |
| 434 GDataErrorCode error = GDATA_OTHER_ERROR; | 434 GDataErrorCode error = GDATA_OTHER_ERROR; |
| 435 scoped_ptr<base::Value> result; | 435 scoped_ptr<base::Value> result; |
| 436 | 436 |
| 437 { | 437 { |
| 438 base::RunLoop run_loop; | 438 base::RunLoop run_loop; |
| 439 GetFilelistRequest* request = new GetFilelistRequest( | 439 GetFilelistRequest* request = new GetFilelistRequest( |
| 440 request_sender_.get(), | 440 request_sender_.get(), |
| 441 *url_generator_, | 441 *url_generator_, |
| 442 "\"abcde\" in parents", | 442 "\"abcde\" in parents", |
| 443 50, // max results | 443 50, // max results |
| 444 test_util::CreateQuitCallback( | 444 test_util::CreateQuitCallback( |
| 445 &run_loop, | 445 &run_loop, |
| 446 test_util::CreateCopyResultCallback(&error, &result))); | 446 test_util::CreateCopyResultCallback(&error, &result))); |
| 447 request_sender_->StartRequestWithRetry(request); | 447 request_sender_->StartRequestWithRetry(request); |
| 448 run_loop.Run(); | 448 run_loop.Run(); |
| 449 } | 449 } |
| 450 | 450 |
| 451 EXPECT_EQ(HTTP_SUCCESS, error); | 451 EXPECT_EQ(HTTP_SUCCESS, error); |
| 452 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); | 452 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); |
| 453 EXPECT_EQ("/drive/v2/files?maxResults=50&q=%22abcde%22+in+parents", | 453 EXPECT_EQ("/drive/v2/files?maxResults=50&q=%22abcde%22+in+parents", |
| 454 http_request_.relative_url); | 454 http_request_.relative_url); |
| 455 EXPECT_TRUE(result); | 455 EXPECT_TRUE(result); |
| 456 } | 456 } |
| 457 | 457 |
| 458 TEST_F(DriveApiRequestsTest, ContinueGetFileListRequest) { | 458 TEST_F(DriveApiRequestsTest, ContinueGetFileListRequest) { |
| 459 // Set an expected data file containing valid result. | 459 // Set an expected data file containing valid result. |
| 460 expected_data_file_path_ = test_util::GetTestFilePath( | 460 expected_data_file_path_ = test_util::GetTestFilePath( |
| 461 "chromeos/drive/filelist.json"); | 461 "drive/filelist.json"); |
| 462 | 462 |
| 463 GDataErrorCode error = GDATA_OTHER_ERROR; | 463 GDataErrorCode error = GDATA_OTHER_ERROR; |
| 464 scoped_ptr<base::Value> result; | 464 scoped_ptr<base::Value> result; |
| 465 | 465 |
| 466 { | 466 { |
| 467 base::RunLoop run_loop; | 467 base::RunLoop run_loop; |
| 468 drive::ContinueGetFileListRequest* request = | 468 drive::ContinueGetFileListRequest* request = |
| 469 new drive::ContinueGetFileListRequest( | 469 new drive::ContinueGetFileListRequest( |
| 470 request_sender_.get(), | 470 request_sender_.get(), |
| 471 test_server_.GetURL("/continue/get/file/list"), | 471 test_server_.GetURL("/continue/get/file/list"), |
| 472 test_util::CreateQuitCallback( | 472 test_util::CreateQuitCallback( |
| 473 &run_loop, | 473 &run_loop, |
| 474 test_util::CreateCopyResultCallback(&error, &result))); | 474 test_util::CreateCopyResultCallback(&error, &result))); |
| 475 request_sender_->StartRequestWithRetry(request); | 475 request_sender_->StartRequestWithRetry(request); |
| 476 run_loop.Run(); | 476 run_loop.Run(); |
| 477 } | 477 } |
| 478 | 478 |
| 479 EXPECT_EQ(HTTP_SUCCESS, error); | 479 EXPECT_EQ(HTTP_SUCCESS, error); |
| 480 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); | 480 EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); |
| 481 EXPECT_EQ("/continue/get/file/list", http_request_.relative_url); | 481 EXPECT_EQ("/continue/get/file/list", http_request_.relative_url); |
| 482 EXPECT_TRUE(result); | 482 EXPECT_TRUE(result); |
| 483 } | 483 } |
| 484 | 484 |
| 485 TEST_F(DriveApiRequestsTest, CreateDirectoryRequest) { | 485 TEST_F(DriveApiRequestsTest, CreateDirectoryRequest) { |
| 486 // Set an expected data file containing the directory's entry data. | 486 // Set an expected data file containing the directory's entry data. |
| 487 expected_data_file_path_ = | 487 expected_data_file_path_ = |
| 488 test_util::GetTestFilePath("chromeos/drive/directory_entry.json"); | 488 test_util::GetTestFilePath("drive/directory_entry.json"); |
| 489 | 489 |
| 490 GDataErrorCode error = GDATA_OTHER_ERROR; | 490 GDataErrorCode error = GDATA_OTHER_ERROR; |
| 491 scoped_ptr<FileResource> file_resource; | 491 scoped_ptr<FileResource> file_resource; |
| 492 | 492 |
| 493 // Create "new directory" in the root directory. | 493 // Create "new directory" in the root directory. |
| 494 { | 494 { |
| 495 base::RunLoop run_loop; | 495 base::RunLoop run_loop; |
| 496 drive::CreateDirectoryRequest* request = | 496 drive::CreateDirectoryRequest* request = |
| 497 new drive::CreateDirectoryRequest( | 497 new drive::CreateDirectoryRequest( |
| 498 request_sender_.get(), | 498 request_sender_.get(), |
| 499 *url_generator_, | 499 *url_generator_, |
| 500 "root", | 500 "root", |
| 501 "new directory", | 501 "new directory", |
| 502 test_util::CreateQuitCallback( | 502 test_util::CreateQuitCallback( |
| 503 &run_loop, | 503 &run_loop, |
| 504 test_util::CreateCopyResultCallback(&error, &file_resource))); | 504 test_util::CreateCopyResultCallback(&error, &file_resource))); |
| 505 request_sender_->StartRequestWithRetry(request); | 505 request_sender_->StartRequestWithRetry(request); |
| 506 run_loop.Run(); | 506 run_loop.Run(); |
| 507 } | 507 } |
| 508 | 508 |
| 509 EXPECT_EQ(HTTP_SUCCESS, error); | 509 EXPECT_EQ(HTTP_SUCCESS, error); |
| 510 EXPECT_EQ(net::test_server::METHOD_POST, http_request_.method); | 510 EXPECT_EQ(net::test_server::METHOD_POST, http_request_.method); |
| 511 EXPECT_EQ("/drive/v2/files", http_request_.relative_url); | 511 EXPECT_EQ("/drive/v2/files", http_request_.relative_url); |
| 512 EXPECT_EQ("application/json", http_request_.headers["Content-Type"]); | 512 EXPECT_EQ("application/json", http_request_.headers["Content-Type"]); |
| 513 | 513 |
| 514 EXPECT_TRUE(http_request_.has_content); | 514 EXPECT_TRUE(http_request_.has_content); |
| 515 | 515 |
| 516 scoped_ptr<FileResource> expected( | 516 scoped_ptr<FileResource> expected( |
| 517 FileResource::CreateFrom( | 517 FileResource::CreateFrom( |
| 518 *test_util::LoadJSONFile("chromeos/drive/directory_entry.json"))); | 518 *test_util::LoadJSONFile("drive/directory_entry.json"))); |
| 519 | 519 |
| 520 // Sanity check. | 520 // Sanity check. |
| 521 ASSERT_TRUE(file_resource.get()); | 521 ASSERT_TRUE(file_resource.get()); |
| 522 | 522 |
| 523 EXPECT_EQ(expected->file_id(), file_resource->file_id()); | 523 EXPECT_EQ(expected->file_id(), file_resource->file_id()); |
| 524 EXPECT_EQ(expected->title(), file_resource->title()); | 524 EXPECT_EQ(expected->title(), file_resource->title()); |
| 525 EXPECT_EQ(expected->mime_type(), file_resource->mime_type()); | 525 EXPECT_EQ(expected->mime_type(), file_resource->mime_type()); |
| 526 EXPECT_EQ(expected->parents().size(), file_resource->parents().size()); | 526 EXPECT_EQ(expected->parents().size(), file_resource->parents().size()); |
| 527 } | 527 } |
| 528 | 528 |
| 529 TEST_F(DriveApiRequestsTest, RenameResourceRequest) { | 529 TEST_F(DriveApiRequestsTest, RenameResourceRequest) { |
| 530 // Set an expected data file containing the directory's entry data. | 530 // Set an expected data file containing the directory's entry data. |
| 531 // It'd be returned if we rename a directory. | 531 // It'd be returned if we rename a directory. |
| 532 expected_data_file_path_ = | 532 expected_data_file_path_ = |
| 533 test_util::GetTestFilePath("chromeos/drive/directory_entry.json"); | 533 test_util::GetTestFilePath("drive/directory_entry.json"); |
| 534 | 534 |
| 535 GDataErrorCode error = GDATA_OTHER_ERROR; | 535 GDataErrorCode error = GDATA_OTHER_ERROR; |
| 536 | 536 |
| 537 // Create "new directory" in the root directory. | 537 // Create "new directory" in the root directory. |
| 538 { | 538 { |
| 539 base::RunLoop run_loop; | 539 base::RunLoop run_loop; |
| 540 drive::RenameResourceRequest* request = | 540 drive::RenameResourceRequest* request = |
| 541 new drive::RenameResourceRequest( | 541 new drive::RenameResourceRequest( |
| 542 request_sender_.get(), | 542 request_sender_.get(), |
| 543 *url_generator_, | 543 *url_generator_, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 556 EXPECT_EQ("application/json", http_request_.headers["Content-Type"]); | 556 EXPECT_EQ("application/json", http_request_.headers["Content-Type"]); |
| 557 | 557 |
| 558 EXPECT_TRUE(http_request_.has_content); | 558 EXPECT_TRUE(http_request_.has_content); |
| 559 EXPECT_EQ("{\"title\":\"new name\"}", http_request_.content); | 559 EXPECT_EQ("{\"title\":\"new name\"}", http_request_.content); |
| 560 } | 560 } |
| 561 | 561 |
| 562 TEST_F(DriveApiRequestsTest, TouchResourceRequest) { | 562 TEST_F(DriveApiRequestsTest, TouchResourceRequest) { |
| 563 // Set an expected data file containing the directory's entry data. | 563 // Set an expected data file containing the directory's entry data. |
| 564 // It'd be returned if we rename a directory. | 564 // It'd be returned if we rename a directory. |
| 565 expected_data_file_path_ = | 565 expected_data_file_path_ = |
| 566 test_util::GetTestFilePath("chromeos/drive/directory_entry.json"); | 566 test_util::GetTestFilePath("drive/directory_entry.json"); |
| 567 | 567 |
| 568 GDataErrorCode error = GDATA_OTHER_ERROR; | 568 GDataErrorCode error = GDATA_OTHER_ERROR; |
| 569 scoped_ptr<FileResource> file_resource; | 569 scoped_ptr<FileResource> file_resource; |
| 570 const base::Time::Exploded kModifiedDate = {2012, 7, 0, 19, 15, 59, 13, 123}; | 570 const base::Time::Exploded kModifiedDate = {2012, 7, 0, 19, 15, 59, 13, 123}; |
| 571 const base::Time::Exploded kLastViewedByMeDate = | 571 const base::Time::Exploded kLastViewedByMeDate = |
| 572 {2013, 7, 0, 19, 15, 59, 13, 123}; | 572 {2013, 7, 0, 19, 15, 59, 13, 123}; |
| 573 | 573 |
| 574 // Touch a file with |resource_id|. | 574 // Touch a file with |resource_id|. |
| 575 { | 575 { |
| 576 base::RunLoop run_loop; | 576 base::RunLoop run_loop; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 597 EXPECT_TRUE(http_request_.has_content); | 597 EXPECT_TRUE(http_request_.has_content); |
| 598 EXPECT_EQ("{\"lastViewedByMeDate\":\"2013-07-19T15:59:13.123Z\"," | 598 EXPECT_EQ("{\"lastViewedByMeDate\":\"2013-07-19T15:59:13.123Z\"," |
| 599 "\"modifiedDate\":\"2012-07-19T15:59:13.123Z\"}", | 599 "\"modifiedDate\":\"2012-07-19T15:59:13.123Z\"}", |
| 600 http_request_.content); | 600 http_request_.content); |
| 601 } | 601 } |
| 602 | 602 |
| 603 TEST_F(DriveApiRequestsTest, CopyResourceRequest) { | 603 TEST_F(DriveApiRequestsTest, CopyResourceRequest) { |
| 604 // Set an expected data file containing the dummy file entry data. | 604 // Set an expected data file containing the dummy file entry data. |
| 605 // It'd be returned if we copy a file. | 605 // It'd be returned if we copy a file. |
| 606 expected_data_file_path_ = | 606 expected_data_file_path_ = |
| 607 test_util::GetTestFilePath("chromeos/drive/file_entry.json"); | 607 test_util::GetTestFilePath("drive/file_entry.json"); |
| 608 | 608 |
| 609 GDataErrorCode error = GDATA_OTHER_ERROR; | 609 GDataErrorCode error = GDATA_OTHER_ERROR; |
| 610 scoped_ptr<FileResource> file_resource; | 610 scoped_ptr<FileResource> file_resource; |
| 611 | 611 |
| 612 // Copy the file to a new file named "new name". | 612 // Copy the file to a new file named "new name". |
| 613 { | 613 { |
| 614 base::RunLoop run_loop; | 614 base::RunLoop run_loop; |
| 615 drive::CopyResourceRequest* request = | 615 drive::CopyResourceRequest* request = |
| 616 new drive::CopyResourceRequest( | 616 new drive::CopyResourceRequest( |
| 617 request_sender_.get(), | 617 request_sender_.get(), |
| (...skipping 17 matching lines...) Expand all Loading... |
| 635 EXPECT_EQ( | 635 EXPECT_EQ( |
| 636 "{\"parents\":[{\"id\":\"parent_resource_id\"}],\"title\":\"new name\"}", | 636 "{\"parents\":[{\"id\":\"parent_resource_id\"}],\"title\":\"new name\"}", |
| 637 http_request_.content); | 637 http_request_.content); |
| 638 EXPECT_TRUE(file_resource); | 638 EXPECT_TRUE(file_resource); |
| 639 } | 639 } |
| 640 | 640 |
| 641 TEST_F(DriveApiRequestsTest, CopyResourceRequest_EmptyParentResourceId) { | 641 TEST_F(DriveApiRequestsTest, CopyResourceRequest_EmptyParentResourceId) { |
| 642 // Set an expected data file containing the dummy file entry data. | 642 // Set an expected data file containing the dummy file entry data. |
| 643 // It'd be returned if we copy a file. | 643 // It'd be returned if we copy a file. |
| 644 expected_data_file_path_ = | 644 expected_data_file_path_ = |
| 645 test_util::GetTestFilePath("chromeos/drive/file_entry.json"); | 645 test_util::GetTestFilePath("drive/file_entry.json"); |
| 646 | 646 |
| 647 GDataErrorCode error = GDATA_OTHER_ERROR; | 647 GDataErrorCode error = GDATA_OTHER_ERROR; |
| 648 scoped_ptr<FileResource> file_resource; | 648 scoped_ptr<FileResource> file_resource; |
| 649 | 649 |
| 650 // Copy the file to a new file named "new name". | 650 // Copy the file to a new file named "new name". |
| 651 { | 651 { |
| 652 base::RunLoop run_loop; | 652 base::RunLoop run_loop; |
| 653 drive::CopyResourceRequest* request = | 653 drive::CopyResourceRequest* request = |
| 654 new drive::CopyResourceRequest( | 654 new drive::CopyResourceRequest( |
| 655 request_sender_.get(), | 655 request_sender_.get(), |
| (...skipping 15 matching lines...) Expand all Loading... |
| 671 | 671 |
| 672 EXPECT_TRUE(http_request_.has_content); | 672 EXPECT_TRUE(http_request_.has_content); |
| 673 EXPECT_EQ("{\"title\":\"new name\"}", http_request_.content); | 673 EXPECT_EQ("{\"title\":\"new name\"}", http_request_.content); |
| 674 EXPECT_TRUE(file_resource); | 674 EXPECT_TRUE(file_resource); |
| 675 } | 675 } |
| 676 | 676 |
| 677 TEST_F(DriveApiRequestsTest, TrashResourceRequest) { | 677 TEST_F(DriveApiRequestsTest, TrashResourceRequest) { |
| 678 // Set data for the expected result. Directory entry should be returned | 678 // Set data for the expected result. Directory entry should be returned |
| 679 // if the trashing entry is a directory, so using it here should be fine. | 679 // if the trashing entry is a directory, so using it here should be fine. |
| 680 expected_data_file_path_ = | 680 expected_data_file_path_ = |
| 681 test_util::GetTestFilePath("chromeos/drive/directory_entry.json"); | 681 test_util::GetTestFilePath("drive/directory_entry.json"); |
| 682 | 682 |
| 683 GDataErrorCode error = GDATA_OTHER_ERROR; | 683 GDataErrorCode error = GDATA_OTHER_ERROR; |
| 684 | 684 |
| 685 // Trash a resource with the given resource id. | 685 // Trash a resource with the given resource id. |
| 686 { | 686 { |
| 687 base::RunLoop run_loop; | 687 base::RunLoop run_loop; |
| 688 drive::TrashResourceRequest* request = | 688 drive::TrashResourceRequest* request = |
| 689 new drive::TrashResourceRequest( | 689 new drive::TrashResourceRequest( |
| 690 request_sender_.get(), | 690 request_sender_.get(), |
| 691 *url_generator_, | 691 *url_generator_, |
| (...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1334 EXPECT_EQ("Conflicting-etag", http_request_.headers["If-Match"]); | 1334 EXPECT_EQ("Conflicting-etag", http_request_.headers["If-Match"]); |
| 1335 | 1335 |
| 1336 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); | 1336 EXPECT_EQ(net::test_server::METHOD_PUT, http_request_.method); |
| 1337 EXPECT_EQ("/upload/drive/v2/files/resource_id?uploadType=resumable", | 1337 EXPECT_EQ("/upload/drive/v2/files/resource_id?uploadType=resumable", |
| 1338 http_request_.relative_url); | 1338 http_request_.relative_url); |
| 1339 EXPECT_TRUE(http_request_.has_content); | 1339 EXPECT_TRUE(http_request_.has_content); |
| 1340 EXPECT_TRUE(http_request_.content.empty()); | 1340 EXPECT_TRUE(http_request_.content.empty()); |
| 1341 } | 1341 } |
| 1342 | 1342 |
| 1343 } // namespace google_apis | 1343 } // namespace google_apis |
| OLD | NEW |