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 <string> | 5 #include <string> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 2425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2436 } | 2436 } |
2437 | 2437 |
2438 TEST_F(GDataFileSystemTest, ContentSearch) { | 2438 TEST_F(GDataFileSystemTest, ContentSearch) { |
2439 LoadRootFeedDocument("root_feed.json"); | 2439 LoadRootFeedDocument("root_feed.json"); |
2440 | 2440 |
2441 mock_doc_service_->set_search_result("search_result_feed.json"); | 2441 mock_doc_service_->set_search_result("search_result_feed.json"); |
2442 | 2442 |
2443 EXPECT_CALL(*mock_doc_service_, GetDocuments(Eq(GURL()), _, "foo", _, _)) | 2443 EXPECT_CALL(*mock_doc_service_, GetDocuments(Eq(GURL()), _, "foo", _, _)) |
2444 .Times(1); | 2444 .Times(1); |
2445 | 2445 |
2446 const SearchResultPair expected_results[] = { | 2446 const SearchResultPair kExpectedResults[] = { |
2447 { "drive/Directory 1/SubDirectory File 1.txt", false }, | 2447 { "drive/Directory 1/SubDirectory File 1.txt", false }, |
2448 { "drive/Directory 1", true } | 2448 { "drive/Directory 1", true } |
2449 }; | 2449 }; |
2450 | 2450 |
2451 SearchCallback callback = base::Bind(&DriveSearchCallback, | 2451 SearchCallback callback = base::Bind(&DriveSearchCallback, |
2452 &message_loop_, expected_results, 2u); | 2452 &message_loop_, kExpectedResults, ARRAYSIZE_UNSAFE(kExpectedResults)); |
2453 | 2453 |
2454 file_system_->Search("foo", callback); | 2454 file_system_->Search("foo", callback); |
2455 message_loop_.Run(); // Wait to get our result. | 2455 message_loop_.Run(); // Wait to get our result. |
| 2456 } |
| 2457 |
| 2458 TEST_F(GDataFileSystemTest, ContentSearchWithNewEntry) { |
| 2459 LoadRootFeedDocument("root_feed.json"); |
| 2460 |
| 2461 // Search result returning two entries "Directory 1/" and |
| 2462 // "Directory 1/SubDirectory Newly Added File.txt". The latter is not |
| 2463 // contained in the root feed. |
| 2464 mock_doc_service_->set_search_result( |
| 2465 "search_result_with_new_entry_feed.json"); |
| 2466 |
| 2467 EXPECT_CALL(*mock_doc_service_, GetDocuments(Eq(GURL()), _, "foo", _, _)) |
| 2468 .Times(1); |
| 2469 |
| 2470 // As the result of the first Search(), only entries in the current file |
| 2471 // system snapshot are expected to be returned. |
| 2472 const SearchResultPair kExpectedResults[] = { |
| 2473 { "drive/Directory 1", true } |
| 2474 }; |
| 2475 |
| 2476 // At the same time, unknown entry should trigger delta feed request. |
| 2477 // This will cause notification to observers (e.g., File Browser) so that |
| 2478 // they can request search again. |
| 2479 EXPECT_CALL(*mock_doc_service_, GetAccountMetadata(_)).Times(1); |
| 2480 EXPECT_CALL(*mock_doc_service_, GetDocuments(Eq(GURL()), _, "", _, _)) |
| 2481 .Times(1); |
| 2482 EXPECT_CALL(*mock_webapps_registry_, UpdateFromFeed(NotNull())).Times(1); |
| 2483 |
| 2484 SearchCallback callback = base::Bind(&DriveSearchCallback, |
| 2485 &message_loop_, kExpectedResults, ARRAYSIZE_UNSAFE(kExpectedResults)); |
| 2486 |
| 2487 file_system_->Search("foo", callback); |
| 2488 message_loop_.Run(); // Wait to get our result. |
2456 } | 2489 } |
2457 | 2490 |
2458 TEST_F(GDataFileSystemTest, ContentSearchEmptyResult) { | 2491 TEST_F(GDataFileSystemTest, ContentSearchEmptyResult) { |
2459 LoadRootFeedDocument("root_feed.json"); | 2492 LoadRootFeedDocument("root_feed.json"); |
2460 | 2493 |
2461 mock_doc_service_->set_search_result("empty_feed.json"); | 2494 mock_doc_service_->set_search_result("empty_feed.json"); |
2462 | 2495 |
2463 EXPECT_CALL(*mock_doc_service_, GetDocuments(Eq(GURL()), _, "foo", _, _)) | 2496 EXPECT_CALL(*mock_doc_service_, GetDocuments(Eq(GURL()), _, "foo", _, _)) |
2464 .Times(1); | 2497 .Times(1); |
2465 | 2498 |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2584 | 2617 |
2585 // Try to close the same file twice. | 2618 // Try to close the same file twice. |
2586 file_system_->CloseFile(kFileInRoot, close_file_callback); | 2619 file_system_->CloseFile(kFileInRoot, close_file_callback); |
2587 message_loop_.Run(); | 2620 message_loop_.Run(); |
2588 | 2621 |
2589 // It must fail. | 2622 // It must fail. |
2590 EXPECT_EQ(GDATA_FILE_ERROR_NOT_FOUND, callback_helper_->last_error_); | 2623 EXPECT_EQ(GDATA_FILE_ERROR_NOT_FOUND, callback_helper_->last_error_); |
2591 } | 2624 } |
2592 | 2625 |
2593 } // namespace gdata | 2626 } // namespace gdata |
OLD | NEW |