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

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: rebase Created 8 years, 4 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 <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
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 2373 matching lines...) Expand 10 before | Expand all | Expand 10 after
2444 .Times(1); 2445 .Times(1);
2445 2446
2446 const SearchResultPair kExpectedResults[] = { 2447 const SearchResultPair kExpectedResults[] = {
2447 { "drive/Directory 1/SubDirectory File 1.txt", false }, 2448 { "drive/Directory 1/SubDirectory File 1.txt", false },
2448 { "drive/Directory 1", true } 2449 { "drive/Directory 1", true }
2449 }; 2450 };
2450 2451
2451 SearchCallback callback = base::Bind(&DriveSearchCallback, 2452 SearchCallback callback = base::Bind(&DriveSearchCallback,
2452 &message_loop_, kExpectedResults, ARRAYSIZE_UNSAFE(kExpectedResults)); 2453 &message_loop_, kExpectedResults, ARRAYSIZE_UNSAFE(kExpectedResults));
2453 2454
2454 file_system_->Search("foo", callback); 2455 file_system_->Search("foo", GURL(), callback);
2455 message_loop_.Run(); // Wait to get our result. 2456 message_loop_.Run(); // Wait to get our result.
2456 } 2457 }
2457 2458
2458 TEST_F(GDataFileSystemTest, ContentSearchWithNewEntry) { 2459 TEST_F(GDataFileSystemTest, ContentSearchWithNewEntry) {
2459 LoadRootFeedDocument("root_feed.json"); 2460 LoadRootFeedDocument("root_feed.json");
2460 2461
2461 // Search result returning two entries "Directory 1/" and 2462 // Search result returning two entries "Directory 1/" and
2462 // "Directory 1/SubDirectory Newly Added File.txt". The latter is not 2463 // "Directory 1/SubDirectory Newly Added File.txt". The latter is not
2463 // contained in the root feed. 2464 // contained in the root feed.
2464 mock_doc_service_->set_search_result( 2465 mock_doc_service_->set_search_result(
(...skipping 12 matching lines...) Expand all
2477 // This will cause notification to observers (e.g., File Browser) so that 2478 // This will cause notification to observers (e.g., File Browser) so that
2478 // they can request search again. 2479 // they can request search again.
2479 EXPECT_CALL(*mock_doc_service_, GetAccountMetadata(_)).Times(1); 2480 EXPECT_CALL(*mock_doc_service_, GetAccountMetadata(_)).Times(1);
2480 EXPECT_CALL(*mock_doc_service_, GetDocuments(Eq(GURL()), _, "", _, _)) 2481 EXPECT_CALL(*mock_doc_service_, GetDocuments(Eq(GURL()), _, "", _, _))
2481 .Times(1); 2482 .Times(1);
2482 EXPECT_CALL(*mock_webapps_registry_, UpdateFromFeed(NotNull())).Times(1); 2483 EXPECT_CALL(*mock_webapps_registry_, UpdateFromFeed(NotNull())).Times(1);
2483 2484
2484 SearchCallback callback = base::Bind(&DriveSearchCallback, 2485 SearchCallback callback = base::Bind(&DriveSearchCallback,
2485 &message_loop_, kExpectedResults, ARRAYSIZE_UNSAFE(kExpectedResults)); 2486 &message_loop_, kExpectedResults, ARRAYSIZE_UNSAFE(kExpectedResults));
2486 2487
2487 file_system_->Search("foo", callback); 2488 file_system_->Search("foo", GURL(), callback);
2488 message_loop_.Run(); // Wait to get our result. 2489 message_loop_.Run(); // Wait to get our result.
2489 } 2490 }
2490 2491
2491 TEST_F(GDataFileSystemTest, ContentSearchEmptyResult) { 2492 TEST_F(GDataFileSystemTest, ContentSearchEmptyResult) {
2492 LoadRootFeedDocument("root_feed.json"); 2493 LoadRootFeedDocument("root_feed.json");
2493 2494
2494 mock_doc_service_->set_search_result("empty_feed.json"); 2495 mock_doc_service_->set_search_result("empty_feed.json");
2495 2496
2496 EXPECT_CALL(*mock_doc_service_, GetDocuments(Eq(GURL()), _, "foo", _, _)) 2497 EXPECT_CALL(*mock_doc_service_, GetDocuments(Eq(GURL()), _, "foo", _, _))
2497 .Times(1); 2498 .Times(1);
2498 2499
2499 const SearchResultPair* expected_results = NULL; 2500 const SearchResultPair* expected_results = NULL;
2500 2501
2501 SearchCallback callback = base::Bind(&DriveSearchCallback, 2502 SearchCallback callback = base::Bind(&DriveSearchCallback,
2502 &message_loop_, expected_results, 0u); 2503 &message_loop_, expected_results, 0u);
2503 2504
2504 file_system_->Search("foo", callback); 2505 file_system_->Search("foo", GURL(), callback);
2505 message_loop_.Run(); // Wait to get our result. 2506 message_loop_.Run(); // Wait to get our result.
2506 } 2507 }
2507 2508
2508 TEST_F(GDataFileSystemTest, GetAvailableSpace) { 2509 TEST_F(GDataFileSystemTest, GetAvailableSpace) {
2509 GetAvailableSpaceCallback callback = 2510 GetAvailableSpaceCallback callback =
2510 base::Bind(&CallbackHelper::GetAvailableSpaceCallback, 2511 base::Bind(&CallbackHelper::GetAvailableSpaceCallback,
2511 callback_helper_.get()); 2512 callback_helper_.get());
2512 2513
2513 EXPECT_CALL(*mock_doc_service_, GetAccountMetadata(_)); 2514 EXPECT_CALL(*mock_doc_service_, GetAccountMetadata(_));
2514 2515
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
2617 2618
2618 // Try to close the same file twice. 2619 // Try to close the same file twice.
2619 file_system_->CloseFile(kFileInRoot, close_file_callback); 2620 file_system_->CloseFile(kFileInRoot, close_file_callback);
2620 message_loop_.Run(); 2621 message_loop_.Run();
2621 2622
2622 // It must fail. 2623 // It must fail.
2623 EXPECT_EQ(GDATA_FILE_ERROR_NOT_FOUND, callback_helper_->last_error_); 2624 EXPECT_EQ(GDATA_FILE_ERROR_NOT_FOUND, callback_helper_->last_error_);
2624 } 2625 }
2625 2626
2626 } // namespace gdata 2627 } // namespace gdata
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/gdata/gdata_file_system_interface.h ('k') | chrome/browser/chromeos/gdata/gdata_operations.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698