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

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

Issue 12833019: Eliminate small CopyResultFromXxxCallback families in drive_test_util. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 9 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
« no previous file with comments | « no previous file | chrome/browser/chromeos/drive/drive_test_util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 2063 matching lines...) Expand 10 before | Expand all | Expand 10 after
2074 2074
2075 file_system_->Search("\"no-match query\"", false, GURL(), callback); 2075 file_system_->Search("\"no-match query\"", false, GURL(), callback);
2076 message_loop_.Run(); // Wait to get our result. 2076 message_loop_.Run(); // Wait to get our result.
2077 } 2077 }
2078 2078
2079 TEST_F(DriveFileSystemTest, GetAvailableSpace) { 2079 TEST_F(DriveFileSystemTest, GetAvailableSpace) {
2080 DriveFileError error = DRIVE_FILE_OK; 2080 DriveFileError error = DRIVE_FILE_OK;
2081 int64 bytes_total; 2081 int64 bytes_total;
2082 int64 bytes_used; 2082 int64 bytes_used;
2083 file_system_->GetAvailableSpace( 2083 file_system_->GetAvailableSpace(
2084 base::Bind(&test_util::CopyResultsFromGetAvailableSpaceCallback, 2084 google_apis::test_util::CreateCopyResultCallback(
2085 &error, &bytes_total, &bytes_used)); 2085 &error, &bytes_total, &bytes_used));
2086 google_apis::test_util::RunBlockingPoolTask(); 2086 google_apis::test_util::RunBlockingPoolTask();
2087 EXPECT_EQ(GG_LONGLONG(6789012345), bytes_used); 2087 EXPECT_EQ(GG_LONGLONG(6789012345), bytes_used);
2088 EXPECT_EQ(GG_LONGLONG(9876543210), bytes_total); 2088 EXPECT_EQ(GG_LONGLONG(9876543210), bytes_total);
2089 } 2089 }
2090 2090
2091 TEST_F(DriveFileSystemTest, RefreshDirectory) { 2091 TEST_F(DriveFileSystemTest, RefreshDirectory) {
2092 ASSERT_TRUE(LoadRootFeedDocument()); 2092 ASSERT_TRUE(LoadRootFeedDocument());
2093 2093
2094 // We'll notify the directory change to the observer. 2094 // We'll notify the directory change to the observer.
2095 EXPECT_CALL(*mock_directory_observer_, 2095 EXPECT_CALL(*mock_directory_observer_,
(...skipping 28 matching lines...) Expand all
2124 2124
2125 // Pretend we have enough space. 2125 // Pretend we have enough space.
2126 fake_free_disk_space_getter_->set_fake_free_disk_space( 2126 fake_free_disk_space_getter_->set_fake_free_disk_space(
2127 file_size + kMinFreeSpace); 2127 file_size + kMinFreeSpace);
2128 2128
2129 // Open kFileInRoot ("drive/File 1.txt"). 2129 // Open kFileInRoot ("drive/File 1.txt").
2130 DriveFileError error = DRIVE_FILE_ERROR_FAILED; 2130 DriveFileError error = DRIVE_FILE_ERROR_FAILED;
2131 base::FilePath file_path; 2131 base::FilePath file_path;
2132 file_system_->OpenFile( 2132 file_system_->OpenFile(
2133 kFileInRoot, 2133 kFileInRoot,
2134 base::Bind(&test_util::CopyResultsFromOpenFileCallbackAndQuit, 2134 google_apis::test_util::CreateCopyResultCallback(&error, &file_path));
2135 &error, &file_path)); 2135 google_apis::test_util::RunBlockingPoolTask();
2136 message_loop_.Run();
2137 const base::FilePath opened_file_path = file_path; 2136 const base::FilePath opened_file_path = file_path;
2138 2137
2139 // Verify that the file was properly opened. 2138 // Verify that the file was properly opened.
2140 EXPECT_EQ(DRIVE_FILE_OK, error); 2139 EXPECT_EQ(DRIVE_FILE_OK, error);
2141 2140
2142 // Try to open the already opened file. 2141 // Try to open the already opened file.
2143 file_system_->OpenFile( 2142 file_system_->OpenFile(
2144 kFileInRoot, 2143 kFileInRoot,
2145 base::Bind(&test_util::CopyResultsFromOpenFileCallbackAndQuit, 2144 google_apis::test_util::CreateCopyResultCallback(&error, &file_path));
2146 &error, &file_path)); 2145 google_apis::test_util::RunBlockingPoolTask();
2147 message_loop_.Run();
2148 2146
2149 // It must fail. 2147 // It must fail.
2150 EXPECT_EQ(DRIVE_FILE_ERROR_IN_USE, error); 2148 EXPECT_EQ(DRIVE_FILE_ERROR_IN_USE, error);
2151 2149
2152 // Verify that the file contents match the expected contents. 2150 // Verify that the file contents match the expected contents.
2153 // The content is "x"s of the file size. 2151 // The content is "x"s of the file size.
2154 const std::string kExpectedContent = "xxxxxxxxxx"; 2152 const std::string kExpectedContent = "xxxxxxxxxx";
2155 std::string cache_file_data; 2153 std::string cache_file_data;
2156 EXPECT_TRUE(file_util::ReadFileToString(opened_file_path, &cache_file_data)); 2154 EXPECT_TRUE(file_util::ReadFileToString(opened_file_path, &cache_file_data));
2157 EXPECT_EQ(kExpectedContent, cache_file_data); 2155 EXPECT_EQ(kExpectedContent, cache_file_data);
2158 2156
2159 DriveCacheEntry cache_entry; 2157 DriveCacheEntry cache_entry;
2160 EXPECT_TRUE(GetCacheEntryFromOriginThread(file_resource_id, file_md5, 2158 EXPECT_TRUE(GetCacheEntryFromOriginThread(file_resource_id, file_md5,
2161 &cache_entry)); 2159 &cache_entry));
2162 EXPECT_TRUE(cache_entry.is_present()); 2160 EXPECT_TRUE(cache_entry.is_present());
2163 EXPECT_TRUE(cache_entry.is_dirty()); 2161 EXPECT_TRUE(cache_entry.is_dirty());
2164 EXPECT_TRUE(cache_entry.is_persistent()); 2162 EXPECT_TRUE(cache_entry.is_persistent());
2165 2163
2166 base::FilePath cache_file_path; 2164 base::FilePath cache_file_path;
2167 cache_->GetFile(file_resource_id, file_md5, 2165 cache_->GetFile(file_resource_id, file_md5,
2168 google_apis::test_util::CreateCopyResultCallback( 2166 google_apis::test_util::CreateCopyResultCallback(
2169 &error, &cache_file_path)); 2167 &error, &cache_file_path));
2170 google_apis::test_util::RunBlockingPoolTask(); 2168 google_apis::test_util::RunBlockingPoolTask();
2171 EXPECT_EQ(DRIVE_FILE_OK, error); 2169 EXPECT_EQ(DRIVE_FILE_OK, error);
2172 EXPECT_EQ(cache_file_path, opened_file_path); 2170 EXPECT_EQ(cache_file_path, opened_file_path);
2173 2171
2174 // Close kFileInRoot ("drive/File 1.txt"). 2172 // Close kFileInRoot ("drive/File 1.txt").
2175 file_system_->CloseFile( 2173 file_system_->CloseFile(
2176 kFileInRoot, 2174 kFileInRoot,
2177 base::Bind(&test_util::CopyResultsFromCloseFileCallbackAndQuit, 2175 google_apis::test_util::CreateCopyResultCallback(&error));
2178 &error)); 2176 google_apis::test_util::RunBlockingPoolTask();
2179 message_loop_.Run();
2180 2177
2181 // Verify that the file was properly closed. 2178 // Verify that the file was properly closed.
2182 EXPECT_EQ(DRIVE_FILE_OK, error); 2179 EXPECT_EQ(DRIVE_FILE_OK, error);
2183 2180
2184 // Verify that the cache state was changed as expected. 2181 // Verify that the cache state was changed as expected.
2185 EXPECT_TRUE(GetCacheEntryFromOriginThread(file_resource_id, file_md5, 2182 EXPECT_TRUE(GetCacheEntryFromOriginThread(file_resource_id, file_md5,
2186 &cache_entry)); 2183 &cache_entry));
2187 EXPECT_TRUE(cache_entry.is_present()); 2184 EXPECT_TRUE(cache_entry.is_present());
2188 EXPECT_TRUE(cache_entry.is_dirty()); 2185 EXPECT_TRUE(cache_entry.is_dirty());
2189 EXPECT_TRUE(cache_entry.is_persistent()); 2186 EXPECT_TRUE(cache_entry.is_persistent());
2190 2187
2191 // Try to close the same file twice. 2188 // Try to close the same file twice.
2192 file_system_->CloseFile( 2189 file_system_->CloseFile(
2193 kFileInRoot, 2190 kFileInRoot,
2194 base::Bind(&test_util::CopyResultsFromCloseFileCallbackAndQuit, 2191 google_apis::test_util::CreateCopyResultCallback(&error));
2195 &error)); 2192 google_apis::test_util::RunBlockingPoolTask();
2196 message_loop_.Run();
2197 2193
2198 // It must fail. 2194 // It must fail.
2199 EXPECT_EQ(DRIVE_FILE_ERROR_NOT_FOUND, error); 2195 EXPECT_EQ(DRIVE_FILE_ERROR_NOT_FOUND, error);
2200 } 2196 }
2201 2197
2202 // TODO(satorux): Testing if WebAppsRegistry is loaded here is awkward. We 2198 // TODO(satorux): Testing if WebAppsRegistry is loaded here is awkward. We
2203 // should move this to change_list_loader_unittest.cc. crbug.com/161703 2199 // should move this to change_list_loader_unittest.cc. crbug.com/161703
2204 TEST_F(DriveFileSystemTest, WebAppsRegistryIsLoaded) { 2200 TEST_F(DriveFileSystemTest, WebAppsRegistryIsLoaded) {
2205 ASSERT_TRUE(SaveTestFileSystem(USE_SERVER_TIMESTAMP)); 2201 ASSERT_TRUE(SaveTestFileSystem(USE_SERVER_TIMESTAMP));
2206 2202
(...skipping 12 matching lines...) Expand all
2219 2215
2220 // An app for foo.exe should now be found, as the registry was loaded. 2216 // An app for foo.exe should now be found, as the registry was loaded.
2221 drive_webapps_registry_->GetWebAppsForFile( 2217 drive_webapps_registry_->GetWebAppsForFile(
2222 base::FilePath(FILE_PATH_LITERAL("foo.exe")), 2218 base::FilePath(FILE_PATH_LITERAL("foo.exe")),
2223 "" /* mime_type */, 2219 "" /* mime_type */,
2224 &apps); 2220 &apps);
2225 EXPECT_EQ(1U, apps.size()); 2221 EXPECT_EQ(1U, apps.size());
2226 } 2222 }
2227 2223
2228 } // namespace drive 2224 } // namespace drive
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/drive/drive_test_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698