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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/file_path.h" | 6 #include "base/file_path.h" |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
9 #include "base/json/json_file_value_serializer.h" | 9 #include "base/json/json_file_value_serializer.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 .WillOnce(MockGetResourceListCallback(google_apis::HTTP_SUCCESS, | 396 .WillOnce(MockGetResourceListCallback(google_apis::HTTP_SUCCESS, |
397 &resource_list)); | 397 &resource_list)); |
398 | 398 |
399 // When file browser tries to read the file, remote filesystem should detect | 399 // When file browser tries to read the file, remote filesystem should detect |
400 // that the cached file is not present on the disk and download it. Mocked | 400 // that the cached file is not present on the disk and download it. Mocked |
401 // download file will create file with the cached name and predetermined | 401 // download file will create file with the cached name and predetermined |
402 // content. This is the file file browser will read content from. | 402 // content. This is the file file browser will read content from. |
403 // Later in the test, file handler will try to open the same file on gdata | 403 // Later in the test, file handler will try to open the same file on gdata |
404 // mount point. This time, DownloadFile should not be called because local | 404 // mount point. This time, DownloadFile should not be called because local |
405 // copy is already present in the cache. | 405 // copy is already present in the cache. |
406 scoped_ptr<base::Value> document_to_download_value( | 406 scoped_ptr<base::Value> file_to_download_value( |
407 LoadJSONFile(kTestDocumentToDownloadEntry)); | 407 LoadJSONFile(kTestDocumentToDownloadEntry)); |
| 408 scoped_ptr<google_apis::ResourceEntry> file_to_download( |
| 409 google_apis::ResourceEntry::ExtractAndParse(*file_to_download_value)); |
408 EXPECT_CALL(*mock_drive_service_, | 410 EXPECT_CALL(*mock_drive_service_, |
409 GetResourceEntry("file:1_file_resource_id", _)) | 411 GetResourceEntry("file:1_file_resource_id", _)) |
410 .WillOnce(MockGetResourceEntryCallback(google_apis::HTTP_SUCCESS, | 412 .WillOnce(MockGetResourceEntryCallback(google_apis::HTTP_SUCCESS, |
411 &document_to_download_value)); | 413 &file_to_download)); |
412 | 414 |
413 // We expect to download url defined in document entry returned by | 415 // We expect to download url defined in document entry returned by |
414 // GetResourceEntry mock implementation. | 416 // GetResourceEntry mock implementation. |
415 EXPECT_CALL(*mock_drive_service_, | 417 EXPECT_CALL(*mock_drive_service_, |
416 DownloadFile(_, _, GURL("https://file_content_url_changed"), | 418 DownloadFile(_, _, GURL("https://file_content_url_changed"), |
417 _, _)) | 419 _, _)) |
418 .WillOnce(MockDownloadFileCallback(google_apis::HTTP_SUCCESS)); | 420 .WillOnce(MockDownloadFileCallback(google_apis::HTTP_SUCCESS)); |
419 | 421 |
420 // On exit, all operations in progress should be cancelled. | 422 // On exit, all operations in progress should be cancelled. |
421 EXPECT_CALL(*mock_drive_service_, CancelAll()); | 423 EXPECT_CALL(*mock_drive_service_, CancelAll()); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 scoped_ptr<base::Value> second_search_value(LoadJSONFile(kTestRootFeed)); | 462 scoped_ptr<base::Value> second_search_value(LoadJSONFile(kTestRootFeed)); |
461 scoped_ptr<google_apis::ResourceList> second_search_list = | 463 scoped_ptr<google_apis::ResourceList> second_search_list = |
462 google_apis::ResourceList::ExtractAndParse(*second_search_value); | 464 google_apis::ResourceList::ExtractAndParse(*second_search_value); |
463 | 465 |
464 EXPECT_CALL(*mock_drive_service_, | 466 EXPECT_CALL(*mock_drive_service_, |
465 GetResourceList(GURL("https://next_feed"), _, "foo", _, _, _)) | 467 GetResourceList(GURL("https://next_feed"), _, "foo", _, _, _)) |
466 .WillOnce(MockGetResourceListCallback(google_apis::HTTP_SUCCESS, | 468 .WillOnce(MockGetResourceListCallback(google_apis::HTTP_SUCCESS, |
467 &second_search_list)); | 469 &second_search_list)); |
468 | 470 |
469 // Test will try to create a snapshot of the returned file. | 471 // Test will try to create a snapshot of the returned file. |
470 scoped_ptr<base::Value> document_to_download_value( | 472 scoped_ptr<base::Value> file_to_download_value( |
471 LoadJSONFile(kTestDocumentToDownloadEntry)); | 473 LoadJSONFile(kTestDocumentToDownloadEntry)); |
| 474 scoped_ptr<google_apis::ResourceEntry> file_to_download( |
| 475 google_apis::ResourceEntry::ExtractAndParse(*file_to_download_value)); |
472 EXPECT_CALL(*mock_drive_service_, | 476 EXPECT_CALL(*mock_drive_service_, |
473 GetResourceEntry("file:1_file_resource_id", _)) | 477 GetResourceEntry("file:1_file_resource_id", _)) |
474 .WillOnce(MockGetResourceEntryCallback(google_apis::HTTP_SUCCESS, | 478 .WillOnce(MockGetResourceEntryCallback(google_apis::HTTP_SUCCESS, |
475 &document_to_download_value)); | 479 &file_to_download)); |
476 | 480 |
477 // We expect to download url defined in document entry returned by | 481 // We expect to download url defined in document entry returned by |
478 // GetResourceEntry mock implementation. | 482 // GetResourceEntry mock implementation. |
479 EXPECT_CALL(*mock_drive_service_, | 483 EXPECT_CALL(*mock_drive_service_, |
480 DownloadFile(_, _, GURL("https://file_content_url_changed"), | 484 DownloadFile(_, _, GURL("https://file_content_url_changed"), |
481 _, _)) | 485 _, _)) |
482 .WillOnce(MockDownloadFileCallback(google_apis::HTTP_SUCCESS)); | 486 .WillOnce(MockDownloadFileCallback(google_apis::HTTP_SUCCESS)); |
483 | 487 |
484 // On exit, all operations in progress should be cancelled. | 488 // On exit, all operations in progress should be cancelled. |
485 EXPECT_CALL(*mock_drive_service_, CancelAll()); | 489 EXPECT_CALL(*mock_drive_service_, CancelAll()); |
486 | 490 |
487 // All is set... RUN THE TEST. | 491 // All is set... RUN THE TEST. |
488 EXPECT_TRUE(RunExtensionSubtest("filebrowser_component", "remote_search.html", | 492 EXPECT_TRUE(RunExtensionSubtest("filebrowser_component", "remote_search.html", |
489 kComponentFlags)) << message_; | 493 kComponentFlags)) << message_; |
490 } | 494 } |
OLD | NEW |