OLD | NEW |
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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 ASSERT_EQ(content_size, | 141 ASSERT_EQ(content_size, |
142 file_util::WriteFile(path, content.c_str(), content_size)); | 142 file_util::WriteFile(path, content.c_str(), content_size)); |
143 } | 143 } |
144 | 144 |
145 // Action used to set mock expectations for DownloadFile(). | 145 // Action used to set mock expectations for DownloadFile(). |
146 ACTION_P(MockDownloadFileCallback, status) { | 146 ACTION_P(MockDownloadFileCallback, status) { |
147 ASSERT_TRUE(content::BrowserThread::PostTaskAndReply( | 147 ASSERT_TRUE(content::BrowserThread::PostTaskAndReply( |
148 content::BrowserThread::FILE, | 148 content::BrowserThread::FILE, |
149 FROM_HERE, | 149 FROM_HERE, |
150 base::Bind(&CreateFileWithContent, arg1, kTestFileContent), | 150 base::Bind(&CreateFileWithContent, arg1, kTestFileContent), |
151 base::Bind(arg3, status, arg2, arg1))); | 151 base::Bind(arg4, status, arg2, arg1))); |
152 } | 152 } |
153 | 153 |
154 } // namespace | 154 } // namespace |
155 | 155 |
156 class FileSystemExtensionApiTest : public ExtensionApiTest { | 156 class FileSystemExtensionApiTest : public ExtensionApiTest { |
157 public: | 157 public: |
158 FileSystemExtensionApiTest() : test_mount_point_("/tmp") { | 158 FileSystemExtensionApiTest() : test_mount_point_("/tmp") { |
159 } | 159 } |
160 | 160 |
161 virtual ~FileSystemExtensionApiTest() {} | 161 virtual ~FileSystemExtensionApiTest() {} |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 LoadJSONFile(kTestDocumentToDownloadEntry)); | 385 LoadJSONFile(kTestDocumentToDownloadEntry)); |
386 EXPECT_CALL(*mock_drive_service_, | 386 EXPECT_CALL(*mock_drive_service_, |
387 GetDocumentEntry("file:1_file_resource_id", _)) | 387 GetDocumentEntry("file:1_file_resource_id", _)) |
388 .WillOnce(MockGetDocumentEntryCallback(gdata::HTTP_SUCCESS, | 388 .WillOnce(MockGetDocumentEntryCallback(gdata::HTTP_SUCCESS, |
389 &document_to_download_value)); | 389 &document_to_download_value)); |
390 | 390 |
391 // We expect to download url defined in document entry returned by | 391 // We expect to download url defined in document entry returned by |
392 // GetDocumentEntry mock implementation. | 392 // GetDocumentEntry mock implementation. |
393 EXPECT_CALL(*mock_drive_service_, | 393 EXPECT_CALL(*mock_drive_service_, |
394 DownloadFile(_, _, GURL("https://file_content_url_changed"), | 394 DownloadFile(_, _, GURL("https://file_content_url_changed"), |
395 _, _)) | 395 _, _, _)) |
396 .WillOnce(MockDownloadFileCallback(gdata::HTTP_SUCCESS)); | 396 .WillOnce(MockDownloadFileCallback(gdata::HTTP_SUCCESS)); |
397 | 397 |
398 // On exit, all operations in progress should be cancelled. | 398 // On exit, all operations in progress should be cancelled. |
399 EXPECT_CALL(*mock_drive_service_, CancelAll()); | 399 EXPECT_CALL(*mock_drive_service_, CancelAll()); |
400 | 400 |
401 // All is set... RUN THE TEST. | 401 // All is set... RUN THE TEST. |
402 EXPECT_TRUE(RunExtensionTest("filesystem_handler")) << message_; | 402 EXPECT_TRUE(RunExtensionTest("filesystem_handler")) << message_; |
403 EXPECT_TRUE(RunExtensionSubtest("filebrowser_component", "remote.html", | 403 EXPECT_TRUE(RunExtensionSubtest("filebrowser_component", "remote.html", |
404 kComponentFlags)) << message_; | 404 kComponentFlags)) << message_; |
405 } | 405 } |
(...skipping 20 matching lines...) Expand all Loading... |
426 LoadJSONFile(kTestDocumentToDownloadEntry)); | 426 LoadJSONFile(kTestDocumentToDownloadEntry)); |
427 EXPECT_CALL(*mock_drive_service_, | 427 EXPECT_CALL(*mock_drive_service_, |
428 GetDocumentEntry("file:1_file_resource_id", _)) | 428 GetDocumentEntry("file:1_file_resource_id", _)) |
429 .WillOnce(MockGetDocumentEntryCallback(gdata::HTTP_SUCCESS, | 429 .WillOnce(MockGetDocumentEntryCallback(gdata::HTTP_SUCCESS, |
430 &document_to_download_value)); | 430 &document_to_download_value)); |
431 | 431 |
432 // We expect to download url defined in document entry returned by | 432 // We expect to download url defined in document entry returned by |
433 // GetDocumentEntry mock implementation. | 433 // GetDocumentEntry mock implementation. |
434 EXPECT_CALL(*mock_drive_service_, | 434 EXPECT_CALL(*mock_drive_service_, |
435 DownloadFile(_, _, GURL("https://file_content_url_changed"), | 435 DownloadFile(_, _, GURL("https://file_content_url_changed"), |
436 _, _)) | 436 _, _, _)) |
437 .WillOnce(MockDownloadFileCallback(gdata::HTTP_SUCCESS)); | 437 .WillOnce(MockDownloadFileCallback(gdata::HTTP_SUCCESS)); |
438 | 438 |
439 // On exit, all operations in progress should be cancelled. | 439 // On exit, all operations in progress should be cancelled. |
440 EXPECT_CALL(*mock_drive_service_, CancelAll()); | 440 EXPECT_CALL(*mock_drive_service_, CancelAll()); |
441 | 441 |
442 // All is set... RUN THE TEST. | 442 // All is set... RUN THE TEST. |
443 EXPECT_TRUE(RunExtensionSubtest("filebrowser_component", "remote_search.html", | 443 EXPECT_TRUE(RunExtensionSubtest("filebrowser_component", "remote_search.html", |
444 kComponentFlags)) << message_; | 444 kComponentFlags)) << message_; |
445 } | 445 } |
OLD | NEW |