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

Side by Side Diff: chrome/browser/chromeos/drive/drive_file_system_unittest.cc

Issue 14113053: chrome: Use base::MessageLoop. (Part 3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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 "chrome/browser/chromeos/drive/drive_file_system.h" 5 #include "chrome/browser/chromeos/drive/drive_file_system.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 45
46 const int64 kLotsOfSpace = kMinFreeSpace * 10; 46 const int64 kLotsOfSpace = kMinFreeSpace * 10;
47 47
48 struct SearchResultPair { 48 struct SearchResultPair {
49 const char* path; 49 const char* path;
50 const bool is_directory; 50 const bool is_directory;
51 }; 51 };
52 52
53 // Callback to DriveFileSystem::Search used in ContentSearch tests. 53 // Callback to DriveFileSystem::Search used in ContentSearch tests.
54 // Verifies returned vector of results and next feed url. 54 // Verifies returned vector of results and next feed url.
55 void DriveSearchCallback( 55 void DriveSearchCallback(base::MessageLoop* message_loop,
56 MessageLoop* message_loop, 56 const SearchResultPair* expected_results,
57 const SearchResultPair* expected_results, 57 size_t expected_results_size,
58 size_t expected_results_size, 58 const GURL& expected_next_feed,
59 const GURL& expected_next_feed, 59 FileError error,
60 FileError error, 60 const GURL& next_feed,
61 const GURL& next_feed, 61 scoped_ptr<std::vector<SearchResultInfo> > results) {
62 scoped_ptr<std::vector<SearchResultInfo> > results) {
63 ASSERT_TRUE(results); 62 ASSERT_TRUE(results);
64 ASSERT_EQ(expected_results_size, results->size()); 63 ASSERT_EQ(expected_results_size, results->size());
65 64
66 for (size_t i = 0; i < results->size(); i++) { 65 for (size_t i = 0; i < results->size(); i++) {
67 EXPECT_EQ(base::FilePath(expected_results[i].path), 66 EXPECT_EQ(base::FilePath(expected_results[i].path),
68 results->at(i).path); 67 results->at(i).path);
69 EXPECT_EQ(expected_results[i].is_directory, 68 EXPECT_EQ(expected_results[i].is_directory,
70 results->at(i).entry_proto.file_info().is_directory()); 69 results->at(i).entry_proto.file_info().is_directory());
71 } 70 }
72 71
73 EXPECT_EQ(expected_next_feed, next_feed); 72 EXPECT_EQ(expected_next_feed, next_feed);
74 73
75 message_loop->Quit(); 74 message_loop->Quit();
76 } 75 }
77 76
78 // Counts the number of files (not directories) in |entries|. 77 // Counts the number of files (not directories) in |entries|.
79 int CountFiles(const DriveEntryProtoVector& entries) { 78 int CountFiles(const DriveEntryProtoVector& entries) {
80 int num_files = 0; 79 int num_files = 0;
81 for (size_t i = 0; i < entries.size(); ++i) { 80 for (size_t i = 0; i < entries.size(); ++i) {
82 if (!entries[i].file_info().is_directory()) 81 if (!entries[i].file_info().is_directory())
83 ++num_files; 82 ++num_files;
84 } 83 }
85 return num_files; 84 return num_files;
86 } 85 }
87 86
88 // Counts the number of invocation, and if it increased up to |expected_counter| 87 // Counts the number of invocation, and if it increased up to |expected_counter|
89 // quits the current message loop. 88 // quits the current message loop.
90 void AsyncInitializationCallback( 89 void AsyncInitializationCallback(int* counter,
91 int* counter, int expected_counter, MessageLoop* message_loop, 90 int expected_counter,
92 FileError error, scoped_ptr<DriveEntryProto> entry) { 91 base::MessageLoop* message_loop,
92 FileError error,
93 scoped_ptr<DriveEntryProto> entry) {
93 if (error != FILE_ERROR_OK || !entry) { 94 if (error != FILE_ERROR_OK || !entry) {
94 // If we hit an error case, quit the message loop immediately. 95 // If we hit an error case, quit the message loop immediately.
95 // Then the expectation in the test case can find it because the actual 96 // Then the expectation in the test case can find it because the actual
96 // value of |counter| is different from the expected one. 97 // value of |counter| is different from the expected one.
97 message_loop->Quit(); 98 message_loop->Quit();
98 return; 99 return;
99 } 100 }
100 101
101 (*counter)++; 102 (*counter)++;
102 if (*counter >= expected_counter) 103 if (*counter >= expected_counter)
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 435
435 std::string edit_url, resource_id; 436 std::string edit_url, resource_id;
436 EXPECT_TRUE(dict_value->GetString("url", &edit_url)); 437 EXPECT_TRUE(dict_value->GetString("url", &edit_url));
437 EXPECT_TRUE(dict_value->GetString("resource_id", &resource_id)); 438 EXPECT_TRUE(dict_value->GetString("resource_id", &resource_id));
438 439
439 EXPECT_EQ(entry_proto.file_specific_info().alternate_url(), 440 EXPECT_EQ(entry_proto.file_specific_info().alternate_url(),
440 edit_url); 441 edit_url);
441 EXPECT_EQ(entry_proto.resource_id(), resource_id); 442 EXPECT_EQ(entry_proto.resource_id(), resource_id);
442 } 443 }
443 444
444 MessageLoopForUI message_loop_; 445 base::MessageLoopForUI message_loop_;
445 content::TestBrowserThread ui_thread_; 446 content::TestBrowserThread ui_thread_;
446 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; 447 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_;
447 scoped_ptr<TestingProfile> profile_; 448 scoped_ptr<TestingProfile> profile_;
448 449
449 scoped_ptr<DriveCache, test_util::DestroyHelperForTests> cache_; 450 scoped_ptr<DriveCache, test_util::DestroyHelperForTests> cache_;
450 scoped_ptr<DriveFileSystem> file_system_; 451 scoped_ptr<DriveFileSystem> file_system_;
451 scoped_ptr<google_apis::FakeDriveService> fake_drive_service_; 452 scoped_ptr<google_apis::FakeDriveService> fake_drive_service_;
452 scoped_ptr<JobScheduler> scheduler_; 453 scoped_ptr<JobScheduler> scheduler_;
453 scoped_ptr<DriveWebAppsRegistry> drive_webapps_registry_; 454 scoped_ptr<DriveWebAppsRegistry> drive_webapps_registry_;
454 scoped_ptr<DriveResourceMetadata, test_util::DestroyHelperForTests> 455 scoped_ptr<DriveResourceMetadata, test_util::DestroyHelperForTests>
(...skipping 1737 matching lines...) Expand 10 before | Expand all | Expand 10 after
2192 entry->resource_id(), 2193 entry->resource_id(),
2193 entry->file_specific_info().file_md5(), 2194 entry->file_specific_info().file_md5(),
2194 google_apis::test_util::CreateCopyResultCallback(&success, &cache_entry)); 2195 google_apis::test_util::CreateCopyResultCallback(&success, &cache_entry));
2195 google_apis::test_util::RunBlockingPoolTask(); 2196 google_apis::test_util::RunBlockingPoolTask();
2196 2197
2197 EXPECT_TRUE(success); 2198 EXPECT_TRUE(success);
2198 EXPECT_FALSE(cache_entry.is_mounted()); 2199 EXPECT_FALSE(cache_entry.is_mounted());
2199 } 2200 }
2200 2201
2201 } // namespace drive 2202 } // namespace drive
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698