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 2403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2414 | 2414 |
2415 EXPECT_CALL(*mock_doc_service_, GetDocuments(Eq(GURL()), _, "foo", _, _)) | 2415 EXPECT_CALL(*mock_doc_service_, GetDocuments(Eq(GURL()), _, "foo", _, _)) |
2416 .Times(1); | 2416 .Times(1); |
2417 | 2417 |
2418 const SearchResultPair expected_results[] = { | 2418 const SearchResultPair expected_results[] = { |
2419 { "drive/Directory 1/SubDirectory File 1.txt", false }, | 2419 { "drive/Directory 1/SubDirectory File 1.txt", false }, |
2420 { "drive/Directory 1", true } | 2420 { "drive/Directory 1", true } |
2421 }; | 2421 }; |
2422 | 2422 |
2423 SearchCallback callback = base::Bind(&DriveSearchCallback, | 2423 SearchCallback callback = base::Bind(&DriveSearchCallback, |
2424 &message_loop_, expected_results, 2u); | 2424 &message_loop_, expected_results, 2u); |
satorux1
2012/07/31 20:48:52
while you are at it, could you also fix this? see
kinaba
2012/08/01 05:34:09
Done.
| |
2425 | 2425 |
2426 file_system_->Search("foo", callback); | 2426 file_system_->Search("foo", callback); |
2427 message_loop_.Run(); // Wait to get our result. | 2427 message_loop_.Run(); // Wait to get our result. |
2428 } | 2428 } |
2429 | 2429 |
2430 TEST_F(GDataFileSystemTest, ContentSearchWithNewEntry) { | |
2431 LoadRootFeedDocument("root_feed.json"); | |
2432 | |
2433 // Search result returning two entries "Directory 1/" and | |
2434 // "Directory 1/SubDirectory Newly Added File.txt". The latter is not | |
2435 // contained in the root feed. | |
2436 mock_doc_service_->set_search_result( | |
2437 "search_result_with_new_entry_feed.json"); | |
2438 | |
2439 EXPECT_CALL(*mock_doc_service_, GetDocuments(Eq(GURL()), _, "foo", _, _)) | |
2440 .Times(1); | |
2441 | |
2442 // Only entries in the current file system snapshot should be returned. | |
satorux1
2012/07/31 20:48:52
I'm confused. I thought we wanted to include the n
satorux1
2012/07/31 20:50:23
Looking at the patch description, we don't need to
kinaba
2012/08/01 05:34:09
Done.
| |
2443 const SearchResultPair expected_results[] = { | |
satorux1
2012/07/31 20:48:52
nit: kExpectedResults
kinaba
2012/08/01 05:34:09
Done.
| |
2444 { "drive/Directory 1", true } | |
2445 }; | |
2446 | |
2447 // Unknown entry should trigger delta feed request. | |
2448 EXPECT_CALL(*mock_doc_service_, GetAccountMetadata(_)).Times(1); | |
2449 EXPECT_CALL(*mock_doc_service_, GetDocuments(Eq(GURL()), _, "", _, _)) | |
2450 .Times(1); | |
2451 EXPECT_CALL(*mock_webapps_registry_, UpdateFromFeed(NotNull())).Times(1); | |
2452 | |
2453 SearchCallback callback = base::Bind(&DriveSearchCallback, | |
2454 &message_loop_, expected_results, 1u); | |
satorux1
2012/07/31 20:48:52
1u -> ARRAYSIZE_UNSAFE(kExpectedResults)
kinaba
2012/08/01 05:34:09
Done.
| |
2455 | |
2456 file_system_->Search("foo", callback); | |
2457 message_loop_.Run(); // Wait to get our result. | |
2458 } | |
2459 | |
2430 TEST_F(GDataFileSystemTest, ContentSearchEmptyResult) { | 2460 TEST_F(GDataFileSystemTest, ContentSearchEmptyResult) { |
2431 LoadRootFeedDocument("root_feed.json"); | 2461 LoadRootFeedDocument("root_feed.json"); |
2432 | 2462 |
2433 mock_doc_service_->set_search_result("empty_feed.json"); | 2463 mock_doc_service_->set_search_result("empty_feed.json"); |
2434 | 2464 |
2435 EXPECT_CALL(*mock_doc_service_, GetDocuments(Eq(GURL()), _, "foo", _, _)) | 2465 EXPECT_CALL(*mock_doc_service_, GetDocuments(Eq(GURL()), _, "foo", _, _)) |
2436 .Times(1); | 2466 .Times(1); |
2437 | 2467 |
2438 const SearchResultPair* expected_results = NULL; | 2468 const SearchResultPair* expected_results = NULL; |
2439 | 2469 |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2556 | 2586 |
2557 // Try to close the same file twice. | 2587 // Try to close the same file twice. |
2558 file_system_->CloseFile(kFileInRoot, close_file_callback); | 2588 file_system_->CloseFile(kFileInRoot, close_file_callback); |
2559 message_loop_.Run(); | 2589 message_loop_.Run(); |
2560 | 2590 |
2561 // It must fail. | 2591 // It must fail. |
2562 EXPECT_EQ(GDATA_FILE_ERROR_NOT_FOUND, callback_helper_->last_error_); | 2592 EXPECT_EQ(GDATA_FILE_ERROR_NOT_FOUND, callback_helper_->last_error_); |
2563 } | 2593 } |
2564 | 2594 |
2565 } // namespace gdata | 2595 } // namespace gdata |
OLD | NEW |