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

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

Issue 10855034: Drive: Remove gdata_params.h (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review (#16) fix & 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 1964 matching lines...) Expand 10 before | Expand all | Expand 10 after
1975 1975
1976 // The file is obtained with the mock DocumentsService. 1976 // The file is obtained with the mock DocumentsService.
1977 EXPECT_CALL(*mock_doc_service_, 1977 EXPECT_CALL(*mock_doc_service_,
1978 DownloadFile(file_in_root, 1978 DownloadFile(file_in_root,
1979 downloaded_file, 1979 downloaded_file,
1980 GURL("https://file_content_url_changed/"), 1980 GURL("https://file_content_url_changed/"),
1981 _, _)) 1981 _, _))
1982 .Times(1); 1982 .Times(1);
1983 1983
1984 file_system_->GetFileByPath(file_in_root, callback, 1984 file_system_->GetFileByPath(file_in_root, callback,
1985 GetDownloadDataCallback()); 1985 GetContentCallback());
1986 test_util::RunBlockingPoolTask(); 1986 test_util::RunBlockingPoolTask();
1987 1987
1988 EXPECT_EQ(GDATA_FILE_OK, callback_helper_->last_error_); 1988 EXPECT_EQ(GDATA_FILE_OK, callback_helper_->last_error_);
1989 EXPECT_EQ(REGULAR_FILE, callback_helper_->file_type_); 1989 EXPECT_EQ(REGULAR_FILE, callback_helper_->file_type_);
1990 EXPECT_EQ(downloaded_file.value(), 1990 EXPECT_EQ(downloaded_file.value(),
1991 callback_helper_->download_path_.value()); 1991 callback_helper_->download_path_.value());
1992 } 1992 }
1993 1993
1994 TEST_F(GDataFileSystemTest, GetFileByPath_FromGData_NoSpaceAtAll) { 1994 TEST_F(GDataFileSystemTest, GetFileByPath_FromGData_NoSpaceAtAll) {
1995 LoadRootFeedDocument("root_feed.json"); 1995 LoadRootFeedDocument("root_feed.json");
(...skipping 20 matching lines...) Expand all
2016 // The file is not obtained with the mock DocumentsService, because of no 2016 // The file is not obtained with the mock DocumentsService, because of no
2017 // space. 2017 // space.
2018 EXPECT_CALL(*mock_doc_service_, 2018 EXPECT_CALL(*mock_doc_service_,
2019 DownloadFile(file_in_root, 2019 DownloadFile(file_in_root,
2020 downloaded_file, 2020 downloaded_file,
2021 GURL("https://file_content_url_changed/"), 2021 GURL("https://file_content_url_changed/"),
2022 _, _)) 2022 _, _))
2023 .Times(0); 2023 .Times(0);
2024 2024
2025 file_system_->GetFileByPath(file_in_root, callback, 2025 file_system_->GetFileByPath(file_in_root, callback,
2026 GetDownloadDataCallback()); 2026 GetContentCallback());
2027 test_util::RunBlockingPoolTask(); 2027 test_util::RunBlockingPoolTask();
2028 2028
2029 EXPECT_EQ(GDATA_FILE_ERROR_NO_SPACE, 2029 EXPECT_EQ(GDATA_FILE_ERROR_NO_SPACE,
2030 callback_helper_->last_error_); 2030 callback_helper_->last_error_);
2031 } 2031 }
2032 2032
2033 TEST_F(GDataFileSystemTest, GetFileByPath_FromGData_NoEnoughSpaceButCanFreeUp) { 2033 TEST_F(GDataFileSystemTest, GetFileByPath_FromGData_NoEnoughSpaceButCanFreeUp) {
2034 LoadRootFeedDocument("root_feed.json"); 2034 LoadRootFeedDocument("root_feed.json");
2035 2035
2036 GetFileCallback callback = 2036 GetFileCallback callback =
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
2070 // The file is obtained with the mock DocumentsService, because of we freed 2070 // The file is obtained with the mock DocumentsService, because of we freed
2071 // up the space. 2071 // up the space.
2072 EXPECT_CALL(*mock_doc_service_, 2072 EXPECT_CALL(*mock_doc_service_,
2073 DownloadFile(file_in_root, 2073 DownloadFile(file_in_root,
2074 downloaded_file, 2074 downloaded_file,
2075 GURL("https://file_content_url_changed/"), 2075 GURL("https://file_content_url_changed/"),
2076 _, _)) 2076 _, _))
2077 .Times(1); 2077 .Times(1);
2078 2078
2079 file_system_->GetFileByPath(file_in_root, callback, 2079 file_system_->GetFileByPath(file_in_root, callback,
2080 GetDownloadDataCallback()); 2080 GetContentCallback());
2081 test_util::RunBlockingPoolTask(); 2081 test_util::RunBlockingPoolTask();
2082 2082
2083 EXPECT_EQ(GDATA_FILE_OK, callback_helper_->last_error_); 2083 EXPECT_EQ(GDATA_FILE_OK, callback_helper_->last_error_);
2084 EXPECT_EQ(REGULAR_FILE, callback_helper_->file_type_); 2084 EXPECT_EQ(REGULAR_FILE, callback_helper_->file_type_);
2085 EXPECT_EQ(downloaded_file.value(), 2085 EXPECT_EQ(downloaded_file.value(),
2086 callback_helper_->download_path_.value()); 2086 callback_helper_->download_path_.value());
2087 2087
2088 // The file should be removed in order to free up space, and the cache 2088 // The file should be removed in order to free up space, and the cache
2089 // entry should also be removed. 2089 // entry should also be removed.
2090 ASSERT_FALSE(CacheEntryExists("<resource_id>", "<md5>")); 2090 ASSERT_FALSE(CacheEntryExists("<resource_id>", "<md5>"));
(...skipping 30 matching lines...) Expand all
2121 2121
2122 // The file is obtained with the mock DocumentsService. 2122 // The file is obtained with the mock DocumentsService.
2123 EXPECT_CALL(*mock_doc_service_, 2123 EXPECT_CALL(*mock_doc_service_,
2124 DownloadFile(file_in_root, 2124 DownloadFile(file_in_root,
2125 downloaded_file, 2125 downloaded_file,
2126 GURL("https://file_content_url_changed/"), 2126 GURL("https://file_content_url_changed/"),
2127 _, _)) 2127 _, _))
2128 .Times(1); 2128 .Times(1);
2129 2129
2130 file_system_->GetFileByPath(file_in_root, callback, 2130 file_system_->GetFileByPath(file_in_root, callback,
2131 GetDownloadDataCallback()); 2131 GetContentCallback());
2132 test_util::RunBlockingPoolTask(); 2132 test_util::RunBlockingPoolTask();
2133 2133
2134 EXPECT_EQ(GDATA_FILE_ERROR_NO_SPACE, 2134 EXPECT_EQ(GDATA_FILE_ERROR_NO_SPACE,
2135 callback_helper_->last_error_); 2135 callback_helper_->last_error_);
2136 } 2136 }
2137 2137
2138 TEST_F(GDataFileSystemTest, GetFileByPath_FromCache) { 2138 TEST_F(GDataFileSystemTest, GetFileByPath_FromCache) {
2139 LoadRootFeedDocument("root_feed.json"); 2139 LoadRootFeedDocument("root_feed.json");
2140 2140
2141 GetFileCallback callback = 2141 GetFileCallback callback =
(...skipping 19 matching lines...) Expand all
2161 2161
2162 // Make sure we don't call downloads at all. 2162 // Make sure we don't call downloads at all.
2163 EXPECT_CALL(*mock_doc_service_, 2163 EXPECT_CALL(*mock_doc_service_,
2164 DownloadFile(file_in_root, 2164 DownloadFile(file_in_root,
2165 downloaded_file, 2165 downloaded_file,
2166 GURL("https://file_content_url_changed/"), 2166 GURL("https://file_content_url_changed/"),
2167 _, _)) 2167 _, _))
2168 .Times(0); 2168 .Times(0);
2169 2169
2170 file_system_->GetFileByPath(file_in_root, callback, 2170 file_system_->GetFileByPath(file_in_root, callback,
2171 GetDownloadDataCallback()); 2171 GetContentCallback());
2172 test_util::RunBlockingPoolTask(); 2172 test_util::RunBlockingPoolTask();
2173 2173
2174 EXPECT_EQ(REGULAR_FILE, callback_helper_->file_type_); 2174 EXPECT_EQ(REGULAR_FILE, callback_helper_->file_type_);
2175 EXPECT_EQ(downloaded_file.value(), 2175 EXPECT_EQ(downloaded_file.value(),
2176 callback_helper_->download_path_.value()); 2176 callback_helper_->download_path_.value());
2177 } 2177 }
2178 2178
2179 TEST_F(GDataFileSystemTest, GetFileByPath_HostedDocument) { 2179 TEST_F(GDataFileSystemTest, GetFileByPath_HostedDocument) {
2180 LoadRootFeedDocument("root_feed.json"); 2180 LoadRootFeedDocument("root_feed.json");
2181 2181
2182 GetFileCallback callback = 2182 GetFileCallback callback =
2183 base::Bind(&CallbackHelper::GetFileCallback, 2183 base::Bind(&CallbackHelper::GetFileCallback,
2184 callback_helper_.get()); 2184 callback_helper_.get());
2185 2185
2186 FilePath file_in_root(FILE_PATH_LITERAL("drive/Document 1.gdoc")); 2186 FilePath file_in_root(FILE_PATH_LITERAL("drive/Document 1.gdoc"));
2187 scoped_ptr<GDataEntryProto> src_entry_proto = 2187 scoped_ptr<GDataEntryProto> src_entry_proto =
2188 GetEntryInfoByPathSync(file_in_root); 2188 GetEntryInfoByPathSync(file_in_root);
2189 ASSERT_TRUE(src_entry_proto.get()); 2189 ASSERT_TRUE(src_entry_proto.get());
2190 2190
2191 file_system_->GetFileByPath(file_in_root, callback, 2191 file_system_->GetFileByPath(file_in_root, callback,
2192 GetDownloadDataCallback()); 2192 GetContentCallback());
2193 test_util::RunBlockingPoolTask(); 2193 test_util::RunBlockingPoolTask();
2194 2194
2195 EXPECT_EQ(HOSTED_DOCUMENT, callback_helper_->file_type_); 2195 EXPECT_EQ(HOSTED_DOCUMENT, callback_helper_->file_type_);
2196 EXPECT_FALSE(callback_helper_->download_path_.empty()); 2196 EXPECT_FALSE(callback_helper_->download_path_.empty());
2197 2197
2198 ASSERT_TRUE(src_entry_proto.get()); 2198 ASSERT_TRUE(src_entry_proto.get());
2199 VerifyHostedDocumentJSONFile(*src_entry_proto, 2199 VerifyHostedDocumentJSONFile(*src_entry_proto,
2200 callback_helper_->download_path_); 2200 callback_helper_->download_path_);
2201 } 2201 }
2202 2202
(...skipping 22 matching lines...) Expand all
2225 // stored in the cache. 2225 // stored in the cache.
2226 EXPECT_CALL(*mock_doc_service_, 2226 EXPECT_CALL(*mock_doc_service_,
2227 DownloadFile(file_in_root, 2227 DownloadFile(file_in_root,
2228 downloaded_file, 2228 downloaded_file,
2229 GURL("https://file_content_url_changed/"), 2229 GURL("https://file_content_url_changed/"),
2230 _, _)) 2230 _, _))
2231 .Times(1); 2231 .Times(1);
2232 2232
2233 file_system_->GetFileByResourceId(entry_proto->resource_id(), 2233 file_system_->GetFileByResourceId(entry_proto->resource_id(),
2234 callback, 2234 callback,
2235 GetDownloadDataCallback()); 2235 GetContentCallback());
2236 test_util::RunBlockingPoolTask(); 2236 test_util::RunBlockingPoolTask();
2237 2237
2238 EXPECT_EQ(REGULAR_FILE, callback_helper_->file_type_); 2238 EXPECT_EQ(REGULAR_FILE, callback_helper_->file_type_);
2239 EXPECT_EQ(downloaded_file.value(), 2239 EXPECT_EQ(downloaded_file.value(),
2240 callback_helper_->download_path_.value()); 2240 callback_helper_->download_path_.value());
2241 } 2241 }
2242 2242
2243 TEST_F(GDataFileSystemTest, GetFileByResourceId_FromCache) { 2243 TEST_F(GDataFileSystemTest, GetFileByResourceId_FromCache) {
2244 LoadRootFeedDocument("root_feed.json"); 2244 LoadRootFeedDocument("root_feed.json");
2245 2245
(...skipping 15 matching lines...) Expand all
2261 test_util::TEST_CACHE_STATE_PRESENT, 2261 test_util::TEST_CACHE_STATE_PRESENT,
2262 GDataCache::CACHE_TYPE_TMP); 2262 GDataCache::CACHE_TYPE_TMP);
2263 2263
2264 // The file is obtained from the cache. 2264 // The file is obtained from the cache.
2265 // Make sure we don't call downloads at all. 2265 // Make sure we don't call downloads at all.
2266 EXPECT_CALL(*mock_doc_service_, DownloadFile(_, _, _, _, _)) 2266 EXPECT_CALL(*mock_doc_service_, DownloadFile(_, _, _, _, _))
2267 .Times(0); 2267 .Times(0);
2268 2268
2269 file_system_->GetFileByResourceId(entry_proto->resource_id(), 2269 file_system_->GetFileByResourceId(entry_proto->resource_id(),
2270 callback, 2270 callback,
2271 GetDownloadDataCallback()); 2271 GetContentCallback());
2272 test_util::RunBlockingPoolTask(); 2272 test_util::RunBlockingPoolTask();
2273 2273
2274 EXPECT_EQ(REGULAR_FILE, callback_helper_->file_type_); 2274 EXPECT_EQ(REGULAR_FILE, callback_helper_->file_type_);
2275 EXPECT_EQ(downloaded_file.value(), 2275 EXPECT_EQ(downloaded_file.value(),
2276 callback_helper_->download_path_.value()); 2276 callback_helper_->download_path_.value());
2277 } 2277 }
2278 2278
2279 TEST_F(GDataFileSystemTest, UpdateFileByResourceId_PersistentFile) { 2279 TEST_F(GDataFileSystemTest, UpdateFileByResourceId_PersistentFile) {
2280 LoadRootFeedDocument("root_feed.json"); 2280 LoadRootFeedDocument("root_feed.json");
2281 2281
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
2618 2618
2619 // Try to close the same file twice. 2619 // Try to close the same file twice.
2620 file_system_->CloseFile(kFileInRoot, close_file_callback); 2620 file_system_->CloseFile(kFileInRoot, close_file_callback);
2621 message_loop_.Run(); 2621 message_loop_.Run();
2622 2622
2623 // It must fail. 2623 // It must fail.
2624 EXPECT_EQ(GDATA_FILE_ERROR_NOT_FOUND, callback_helper_->last_error_); 2624 EXPECT_EQ(GDATA_FILE_ERROR_NOT_FOUND, callback_helper_->last_error_);
2625 } 2625 }
2626 2626
2627 } // namespace gdata 2627 } // namespace gdata
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/gdata/gdata_file_system_proxy.cc ('k') | chrome/browser/chromeos/gdata/gdata_files.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698