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

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

Issue 10274002: Add gdata content search (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed satorux's comments 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
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 23 matching lines...) Expand all
34 using ::testing::_; 34 using ::testing::_;
35 using ::testing::Return; 35 using ::testing::Return;
36 using content::BrowserContext; 36 using content::BrowserContext;
37 37
38 namespace { 38 namespace {
39 39
40 // These should match the counterparts in remote.js. 40 // These should match the counterparts in remote.js.
41 const char kTestFileContents[] = "hello, world"; 41 const char kTestFileContents[] = "hello, world";
42 42
43 // Contains a folder entry for the folder 'Folder' that will be 'created'. 43 // Contains a folder entry for the folder 'Folder' that will be 'created'.
44 const char kTestDirectory[] = "remote_file_system_apitest_folder_entry.json"; 44 const char kTestDirectory[] = "new_folder_entry.json";
45 45
46 // Contains a folder named Folder that has a file File.aBc inside of it. 46 // Contains a folder named Folder that has a file File.aBc inside of it.
47 const char kTestRootFeed[] = "remote_file_system_apitest_root_feed.json"; 47 const char kTestRootFeed[] = "remote_file_system_apitest_root_feed.json";
48 48
49 // The ID of the file browser extension. 49 // The ID of the file browser extension.
50 const char kFileBrowserExtensionId[] = "ddammdhioacbehjngdmkjcjbnfginlla"; 50 const char kFileBrowserExtensionId[] = "ddammdhioacbehjngdmkjcjbnfginlla";
51 51
52 // Flags used to run the tests with a COMPONENT extension. 52 // Flags used to run the tests with a COMPONENT extension.
53 const int kComponentFlags = ExtensionApiTest::kFlagEnableFileAccess | 53 const int kComponentFlags = ExtensionApiTest::kFlagEnableFileAccess |
54 ExtensionApiTest::kFlagLoadAsComponent; 54 ExtensionApiTest::kFlagLoadAsComponent;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 109
110 // Action used to set mock expectations for CreateDirectory(). 110 // Action used to set mock expectations for CreateDirectory().
111 ACTION_P2(MockCreateDirectoryCallback, status, value) { 111 ACTION_P2(MockCreateDirectoryCallback, status, value) {
112 base::MessageLoopProxy::current()->PostTask(FROM_HERE, 112 base::MessageLoopProxy::current()->PostTask(FROM_HERE,
113 base::Bind(arg2, status, base::Passed(value))); 113 base::Bind(arg2, status, base::Passed(value)));
114 } 114 }
115 115
116 // Action used to set mock expecteations for GetDocuments. 116 // Action used to set mock expecteations for GetDocuments.
117 ACTION_P2(MockGetDocumentsCallback, status, value) { 117 ACTION_P2(MockGetDocumentsCallback, status, value) {
118 base::MessageLoopProxy::current()->PostTask(FROM_HERE, 118 base::MessageLoopProxy::current()->PostTask(FROM_HERE,
119 base::Bind(arg2, status, base::Passed(value))); 119 base::Bind(arg3, status, base::Passed(value)));
120 } 120 }
121 121
122 // Creates a cache representation of the test file with predetermined content. 122 // Creates a cache representation of the test file with predetermined content.
123 void CreateDownloadFile(const FilePath& path) { 123 void CreateDownloadFile(const FilePath& path) {
124 int file_content_size = static_cast<int>(sizeof(kTestFileContents)); 124 int file_content_size = static_cast<int>(sizeof(kTestFileContents));
125 ASSERT_EQ(file_content_size, 125 ASSERT_EQ(file_content_size,
126 file_util::WriteFile(path, kTestFileContents, file_content_size)); 126 file_util::WriteFile(path, kTestFileContents, file_content_size));
127 } 127 }
128 128
129 // Action used to set mock expectations for DownloadFile(). 129 // Action used to set mock expectations for DownloadFile().
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 // First, file browser will try to create new directory. 260 // First, file browser will try to create new directory.
261 scoped_ptr<base::Value> dir_value(LoadJSONFile(kTestDirectory)); 261 scoped_ptr<base::Value> dir_value(LoadJSONFile(kTestDirectory));
262 EXPECT_CALL(*mock_documents_service_, 262 EXPECT_CALL(*mock_documents_service_,
263 CreateDirectory(_, _, _)) 263 CreateDirectory(_, _, _))
264 .WillOnce(MockCreateDirectoryCallback(gdata::HTTP_SUCCESS, &dir_value)); 264 .WillOnce(MockCreateDirectoryCallback(gdata::HTTP_SUCCESS, &dir_value));
265 265
266 // Then the test will try to read an existing file file. 266 // Then the test will try to read an existing file file.
267 // Remote filesystem should first request root feed from gdata server. 267 // Remote filesystem should first request root feed from gdata server.
268 scoped_ptr<base::Value> documents_value(LoadJSONFile(kTestRootFeed)); 268 scoped_ptr<base::Value> documents_value(LoadJSONFile(kTestRootFeed));
269 EXPECT_CALL(*mock_documents_service_, 269 EXPECT_CALL(*mock_documents_service_,
270 GetDocuments(_, _, _)) 270 GetDocuments(_, _, _, _))
271 .WillOnce(MockGetDocumentsCallback(gdata::HTTP_SUCCESS, 271 .WillOnce(MockGetDocumentsCallback(gdata::HTTP_SUCCESS,
272 &documents_value)); 272 &documents_value));
273 273
274 // When file browser tries to read the file, remote filesystem should detect 274 // When file browser tries to read the file, remote filesystem should detect
275 // that the cached file is not present on the disk and download it. Mocked 275 // that the cached file is not present on the disk and download it. Mocked
276 // download file will create file with the cached name and predetermined 276 // download file will create file with the cached name and predetermined
277 // content. This is the file file browser will read content from. 277 // content. This is the file file browser will read content from.
278 // Later in the test, file handler will try to open the same file on gdata 278 // Later in the test, file handler will try to open the same file on gdata
279 // mount point. This time, DownloadFile should not be called because local 279 // mount point. This time, DownloadFile should not be called because local
280 // copy is already present in the cache. 280 // copy is already present in the cache.
281 EXPECT_CALL(*mock_documents_service_, 281 EXPECT_CALL(*mock_documents_service_,
282 DownloadFile(_, _, _, _, _)) 282 DownloadFile(_, _, _, _, _))
283 .WillOnce(MockDownloadFileCallback(gdata::HTTP_SUCCESS)); 283 .WillOnce(MockDownloadFileCallback(gdata::HTTP_SUCCESS));
284 284
285 // On exit, all operations in progress should be cancelled. 285 // On exit, all operations in progress should be cancelled.
286 EXPECT_CALL(*mock_documents_service_, CancelAll()); 286 EXPECT_CALL(*mock_documents_service_, CancelAll());
287 // This one is called on exit, but we don't care much about it, as long as it 287 // This one is called on exit, but we don't care much about it, as long as it
288 // retunrs something valid (i.e. not NULL). 288 // retunrs something valid (i.e. not NULL).
289 EXPECT_CALL(*mock_documents_service_, operation_registry()). 289 EXPECT_CALL(*mock_documents_service_, operation_registry()).
290 WillOnce(Return(operation_registry_.get())); 290 WillOnce(Return(operation_registry_.get()));
291 291
292 // All is set... RUN THE TEST. 292 // All is set... RUN THE TEST.
293 EXPECT_TRUE(RunExtensionTest("filesystem_handler")) << message_; 293 EXPECT_TRUE(RunExtensionTest("filesystem_handler")) << message_;
294 EXPECT_TRUE(RunExtensionSubtest("filebrowser_component", "remote.html", 294 EXPECT_TRUE(RunExtensionSubtest("filebrowser_component", "remote.html",
295 kComponentFlags)) << message_; 295 kComponentFlags)) << message_;
296 } 296 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698