Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(263)

Side by Side Diff: chrome/browser/chromeos/gdata/gdata_file_system_unittest.cc

Issue 10634020: [FileManager] Do drive search incrementally (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 <errno.h> 5 #include <errno.h>
6 #include <string> 6 #include <string>
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 const bool is_directory; 79 const bool is_directory;
80 }; 80 };
81 81
82 // Callback to GDataFileSystem::Search used in ContentSearch tests. 82 // Callback to GDataFileSystem::Search used in ContentSearch tests.
83 // Verifies returned vector of results. 83 // Verifies returned vector of results.
84 void DriveSearchCallback( 84 void DriveSearchCallback(
85 MessageLoop* message_loop, 85 MessageLoop* message_loop,
86 const SearchResultPair* expected_results, 86 const SearchResultPair* expected_results,
87 size_t expected_results_size, 87 size_t expected_results_size,
88 GDataFileError error, 88 GDataFileError error,
89 const GURL& next_feed,
89 scoped_ptr<std::vector<SearchResultInfo> > results) { 90 scoped_ptr<std::vector<SearchResultInfo> > results) {
90 ASSERT_TRUE(results.get()); 91 ASSERT_TRUE(results.get());
91 ASSERT_EQ(expected_results_size, results->size()); 92 ASSERT_EQ(expected_results_size, results->size());
92 93
93 for (size_t i = 0; i < results->size(); i++) { 94 for (size_t i = 0; i < results->size(); i++) {
94 EXPECT_EQ(FilePath(expected_results[i].path), 95 EXPECT_EQ(FilePath(expected_results[i].path),
95 results->at(i).path); 96 results->at(i).path);
96 EXPECT_EQ(expected_results[i].is_directory, 97 EXPECT_EQ(expected_results[i].is_directory,
97 results->at(i).is_directory); 98 results->at(i).is_directory);
98 } 99 }
(...skipping 2348 matching lines...) Expand 10 before | Expand all | Expand 10 after
2447 .Times(1); 2448 .Times(1);
2448 2449
2449 const SearchResultPair expected_results[] = { 2450 const SearchResultPair expected_results[] = {
2450 { "drive/Directory 1/SubDirectory File 1.txt", false }, 2451 { "drive/Directory 1/SubDirectory File 1.txt", false },
2451 { "drive/Directory 1", true } 2452 { "drive/Directory 1", true }
2452 }; 2453 };
2453 2454
2454 SearchCallback callback = base::Bind(&DriveSearchCallback, 2455 SearchCallback callback = base::Bind(&DriveSearchCallback,
2455 &message_loop_, expected_results, 2u); 2456 &message_loop_, expected_results, 2u);
2456 2457
2457 file_system_->Search("foo", callback); 2458 file_system_->Search("foo", GURL(), callback);
2458 message_loop_.Run(); // Wait to get our result. 2459 message_loop_.Run(); // Wait to get our result.
2459 } 2460 }
2460 2461
2461 TEST_F(GDataFileSystemTest, ContentSearchEmptyResult) { 2462 TEST_F(GDataFileSystemTest, ContentSearchEmptyResult) {
2462 LoadRootFeedDocument("root_feed.json"); 2463 LoadRootFeedDocument("root_feed.json");
2463 2464
2464 mock_doc_service_->set_search_result("empty_feed.json"); 2465 mock_doc_service_->set_search_result("empty_feed.json");
2465 2466
2466 EXPECT_CALL(*mock_doc_service_, GetDocuments(Eq(GURL()), _, "foo", _, _)) 2467 EXPECT_CALL(*mock_doc_service_, GetDocuments(Eq(GURL()), _, "foo", _, _))
2467 .Times(1); 2468 .Times(1);
2468 2469
2469 const SearchResultPair* expected_results = NULL; 2470 const SearchResultPair* expected_results = NULL;
2470 2471
2471 SearchCallback callback = base::Bind(&DriveSearchCallback, 2472 SearchCallback callback = base::Bind(&DriveSearchCallback,
2472 &message_loop_, expected_results, 0u); 2473 &message_loop_, expected_results, 0u);
2473 2474
2474 file_system_->Search("foo", callback); 2475 file_system_->Search("foo", GURL(), callback);
2475 message_loop_.Run(); // Wait to get our result. 2476 message_loop_.Run(); // Wait to get our result.
2476 } 2477 }
2477 2478
2478 TEST_F(GDataFileSystemTest, GetAvailableSpace) { 2479 TEST_F(GDataFileSystemTest, GetAvailableSpace) {
2479 GetAvailableSpaceCallback callback = 2480 GetAvailableSpaceCallback callback =
2480 base::Bind(&CallbackHelper::GetAvailableSpaceCallback, 2481 base::Bind(&CallbackHelper::GetAvailableSpaceCallback,
2481 callback_helper_.get()); 2482 callback_helper_.get());
2482 2483
2483 EXPECT_CALL(*mock_doc_service_, GetAccountMetadata(_)); 2484 EXPECT_CALL(*mock_doc_service_, GetAccountMetadata(_));
2484 2485
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
2586 2587
2587 // Try to close the same file twice. 2588 // Try to close the same file twice.
2588 file_system_->CloseFile(kFileInRoot, close_file_callback); 2589 file_system_->CloseFile(kFileInRoot, close_file_callback);
2589 message_loop_.Run(); 2590 message_loop_.Run();
2590 2591
2591 // It must fail. 2592 // It must fail.
2592 EXPECT_EQ(GDATA_FILE_ERROR_NOT_FOUND, callback_helper_->last_error_); 2593 EXPECT_EQ(GDATA_FILE_ERROR_NOT_FOUND, callback_helper_->last_error_);
2593 } 2594 }
2594 2595
2595 } // namespace gdata 2596 } // namespace gdata
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698