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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 const bool is_directory; | 51 const bool is_directory; |
52 }; | 52 }; |
53 | 53 |
54 // Callback to GDataFileSystem::Search used in ContentSearch tests. | 54 // Callback to GDataFileSystem::Search used in ContentSearch tests. |
55 // Verifies returned vector of results. | 55 // Verifies returned vector of results. |
56 void DriveSearchCallback( | 56 void DriveSearchCallback( |
57 MessageLoop* message_loop, | 57 MessageLoop* message_loop, |
58 const SearchResultPair* expected_results, | 58 const SearchResultPair* expected_results, |
59 size_t expected_results_size, | 59 size_t expected_results_size, |
60 GDataFileError error, | 60 GDataFileError error, |
| 61 const GURL& next_feed, |
61 scoped_ptr<std::vector<SearchResultInfo> > results) { | 62 scoped_ptr<std::vector<SearchResultInfo> > results) { |
62 ASSERT_TRUE(results.get()); | 63 ASSERT_TRUE(results.get()); |
63 ASSERT_EQ(expected_results_size, results->size()); | 64 ASSERT_EQ(expected_results_size, results->size()); |
64 | 65 |
65 for (size_t i = 0; i < results->size(); i++) { | 66 for (size_t i = 0; i < results->size(); i++) { |
66 EXPECT_EQ(FilePath(expected_results[i].path), | 67 EXPECT_EQ(FilePath(expected_results[i].path), |
67 results->at(i).path); | 68 results->at(i).path); |
68 EXPECT_EQ(expected_results[i].is_directory, | 69 EXPECT_EQ(expected_results[i].is_directory, |
69 results->at(i).is_directory); | 70 results->at(i).is_directory); |
70 } | 71 } |
(...skipping 2345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2416 .Times(1); | 2417 .Times(1); |
2417 | 2418 |
2418 const SearchResultPair expected_results[] = { | 2419 const SearchResultPair expected_results[] = { |
2419 { "drive/Directory 1/SubDirectory File 1.txt", false }, | 2420 { "drive/Directory 1/SubDirectory File 1.txt", false }, |
2420 { "drive/Directory 1", true } | 2421 { "drive/Directory 1", true } |
2421 }; | 2422 }; |
2422 | 2423 |
2423 SearchCallback callback = base::Bind(&DriveSearchCallback, | 2424 SearchCallback callback = base::Bind(&DriveSearchCallback, |
2424 &message_loop_, expected_results, 2u); | 2425 &message_loop_, expected_results, 2u); |
2425 | 2426 |
2426 file_system_->Search("foo", callback); | 2427 file_system_->Search("foo", GURL(), callback); |
2427 message_loop_.Run(); // Wait to get our result. | 2428 message_loop_.Run(); // Wait to get our result. |
2428 } | 2429 } |
2429 | 2430 |
2430 TEST_F(GDataFileSystemTest, ContentSearchEmptyResult) { | 2431 TEST_F(GDataFileSystemTest, ContentSearchEmptyResult) { |
2431 LoadRootFeedDocument("root_feed.json"); | 2432 LoadRootFeedDocument("root_feed.json"); |
2432 | 2433 |
2433 mock_doc_service_->set_search_result("empty_feed.json"); | 2434 mock_doc_service_->set_search_result("empty_feed.json"); |
2434 | 2435 |
2435 EXPECT_CALL(*mock_doc_service_, GetDocuments(Eq(GURL()), _, "foo", _, _)) | 2436 EXPECT_CALL(*mock_doc_service_, GetDocuments(Eq(GURL()), _, "foo", _, _)) |
2436 .Times(1); | 2437 .Times(1); |
2437 | 2438 |
2438 const SearchResultPair* expected_results = NULL; | 2439 const SearchResultPair* expected_results = NULL; |
2439 | 2440 |
2440 SearchCallback callback = base::Bind(&DriveSearchCallback, | 2441 SearchCallback callback = base::Bind(&DriveSearchCallback, |
2441 &message_loop_, expected_results, 0u); | 2442 &message_loop_, expected_results, 0u); |
2442 | 2443 |
2443 file_system_->Search("foo", callback); | 2444 file_system_->Search("foo", GURL(), callback); |
2444 message_loop_.Run(); // Wait to get our result. | 2445 message_loop_.Run(); // Wait to get our result. |
2445 } | 2446 } |
2446 | 2447 |
2447 TEST_F(GDataFileSystemTest, GetAvailableSpace) { | 2448 TEST_F(GDataFileSystemTest, GetAvailableSpace) { |
2448 GetAvailableSpaceCallback callback = | 2449 GetAvailableSpaceCallback callback = |
2449 base::Bind(&CallbackHelper::GetAvailableSpaceCallback, | 2450 base::Bind(&CallbackHelper::GetAvailableSpaceCallback, |
2450 callback_helper_.get()); | 2451 callback_helper_.get()); |
2451 | 2452 |
2452 EXPECT_CALL(*mock_doc_service_, GetAccountMetadata(_)); | 2453 EXPECT_CALL(*mock_doc_service_, GetAccountMetadata(_)); |
2453 | 2454 |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2556 | 2557 |
2557 // Try to close the same file twice. | 2558 // Try to close the same file twice. |
2558 file_system_->CloseFile(kFileInRoot, close_file_callback); | 2559 file_system_->CloseFile(kFileInRoot, close_file_callback); |
2559 message_loop_.Run(); | 2560 message_loop_.Run(); |
2560 | 2561 |
2561 // It must fail. | 2562 // It must fail. |
2562 EXPECT_EQ(GDATA_FILE_ERROR_NOT_FOUND, callback_helper_->last_error_); | 2563 EXPECT_EQ(GDATA_FILE_ERROR_NOT_FOUND, callback_helper_->last_error_); |
2563 } | 2564 } |
2564 | 2565 |
2565 } // namespace gdata | 2566 } // namespace gdata |
OLD | NEW |