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

Side by Side Diff: chrome/browser/chromeos/extensions/external_filesystem_apitest.cc

Issue 10383248: gdata: Add ability to fetch documents in a particular directory (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix the build Created 8 years, 7 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/gdata/gdata_documents_service.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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/file_path.h" 6 #include "base/file_path.h"
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/json/json_file_value_serializer.h" 8 #include "base/json/json_file_value_serializer.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop_proxy.h" 10 #include "base/message_loop_proxy.h"
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 111
112 // Action used to set mock expectations for CreateDirectory(). 112 // Action used to set mock expectations for CreateDirectory().
113 ACTION_P2(MockCreateDirectoryCallback, status, value) { 113 ACTION_P2(MockCreateDirectoryCallback, status, value) {
114 base::MessageLoopProxy::current()->PostTask(FROM_HERE, 114 base::MessageLoopProxy::current()->PostTask(FROM_HERE,
115 base::Bind(arg2, status, base::Passed(value))); 115 base::Bind(arg2, status, base::Passed(value)));
116 } 116 }
117 117
118 // Action used to set mock expecteations for GetDocuments. 118 // Action used to set mock expecteations for GetDocuments.
119 ACTION_P2(MockGetDocumentsCallback, status, value) { 119 ACTION_P2(MockGetDocumentsCallback, status, value) {
120 base::MessageLoopProxy::current()->PostTask(FROM_HERE, 120 base::MessageLoopProxy::current()->PostTask(FROM_HERE,
121 base::Bind(arg3, status, base::Passed(value))); 121 base::Bind(arg4, status, base::Passed(value)));
122 } 122 }
123 123
124 // Creates a cache representation of the test file with predetermined content. 124 // Creates a cache representation of the test file with predetermined content.
125 void CreateDownloadFile(const FilePath& path) { 125 void CreateDownloadFile(const FilePath& path) {
126 int file_content_size = static_cast<int>(sizeof(kTestFileContents)); 126 int file_content_size = static_cast<int>(sizeof(kTestFileContents));
127 ASSERT_EQ(file_content_size, 127 ASSERT_EQ(file_content_size,
128 file_util::WriteFile(path, kTestFileContents, file_content_size)); 128 file_util::WriteFile(path, kTestFileContents, file_content_size));
129 } 129 }
130 130
131 // Action used to set mock expectations for DownloadFile(). 131 // Action used to set mock expectations for DownloadFile().
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 // First, file browser will try to create new directory. 265 // First, file browser will try to create new directory.
266 scoped_ptr<base::Value> dir_value(LoadJSONFile(kTestDirectory)); 266 scoped_ptr<base::Value> dir_value(LoadJSONFile(kTestDirectory));
267 EXPECT_CALL(*mock_documents_service_, 267 EXPECT_CALL(*mock_documents_service_,
268 CreateDirectory(_, _, _)) 268 CreateDirectory(_, _, _))
269 .WillOnce(MockCreateDirectoryCallback(gdata::HTTP_SUCCESS, &dir_value)); 269 .WillOnce(MockCreateDirectoryCallback(gdata::HTTP_SUCCESS, &dir_value));
270 270
271 // Then the test will try to read an existing file file. 271 // Then the test will try to read an existing file file.
272 // Remote filesystem should first request root feed from gdata server. 272 // Remote filesystem should first request root feed from gdata server.
273 scoped_ptr<base::Value> documents_value(LoadJSONFile(kTestRootFeed)); 273 scoped_ptr<base::Value> documents_value(LoadJSONFile(kTestRootFeed));
274 EXPECT_CALL(*mock_documents_service_, 274 EXPECT_CALL(*mock_documents_service_,
275 GetDocuments(_, _, _, _)) 275 GetDocuments(_, _, _, _, _))
276 .WillOnce(MockGetDocumentsCallback(gdata::HTTP_SUCCESS, 276 .WillOnce(MockGetDocumentsCallback(gdata::HTTP_SUCCESS,
277 &documents_value)); 277 &documents_value));
278 278
279 // When file browser tries to read the file, remote filesystem should detect 279 // When file browser tries to read the file, remote filesystem should detect
280 // that the cached file is not present on the disk and download it. Mocked 280 // that the cached file is not present on the disk and download it. Mocked
281 // download file will create file with the cached name and predetermined 281 // download file will create file with the cached name and predetermined
282 // content. This is the file file browser will read content from. 282 // content. This is the file file browser will read content from.
283 // Later in the test, file handler will try to open the same file on gdata 283 // Later in the test, file handler will try to open the same file on gdata
284 // mount point. This time, DownloadFile should not be called because local 284 // mount point. This time, DownloadFile should not be called because local
285 // copy is already present in the cache. 285 // copy is already present in the cache.
286 EXPECT_CALL(*mock_documents_service_, 286 EXPECT_CALL(*mock_documents_service_,
287 DownloadFile(_, _, _, _, _)) 287 DownloadFile(_, _, _, _, _))
288 .WillOnce(MockDownloadFileCallback(gdata::HTTP_SUCCESS)); 288 .WillOnce(MockDownloadFileCallback(gdata::HTTP_SUCCESS));
289 289
290 // On exit, all operations in progress should be cancelled. 290 // On exit, all operations in progress should be cancelled.
291 EXPECT_CALL(*mock_documents_service_, CancelAll()); 291 EXPECT_CALL(*mock_documents_service_, CancelAll());
292 // This one is called on exit, but we don't care much about it, as long as it 292 // This one is called on exit, but we don't care much about it, as long as it
293 // retunrs something valid (i.e. not NULL). 293 // retunrs something valid (i.e. not NULL).
294 EXPECT_CALL(*mock_documents_service_, operation_registry()). 294 EXPECT_CALL(*mock_documents_service_, operation_registry()).
295 WillOnce(Return(operation_registry_.get())); 295 WillOnce(Return(operation_registry_.get()));
296 296
297 // All is set... RUN THE TEST. 297 // All is set... RUN THE TEST.
298 EXPECT_TRUE(RunExtensionTest("filesystem_handler")) << message_; 298 EXPECT_TRUE(RunExtensionTest("filesystem_handler")) << message_;
299 EXPECT_TRUE(RunExtensionSubtest("filebrowser_component", "remote.html", 299 EXPECT_TRUE(RunExtensionSubtest("filebrowser_component", "remote.html",
300 kComponentFlags)) << message_; 300 kComponentFlags)) << message_;
301 } 301 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/gdata/gdata_documents_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698