| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/file_task_executor.h" | 5 #include "chrome/browser/chromeos/drive/file_task_executor.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 std::vector<storage::FileSystemURL> urls; | 102 std::vector<storage::FileSystemURL> urls; |
| 103 urls.push_back(storage::FileSystemURL::CreateForTest( | 103 urls.push_back(storage::FileSystemURL::CreateForTest( |
| 104 GURL("http://origin/"), | 104 GURL("http://origin/"), |
| 105 storage::kFileSystemTypeDrive, | 105 storage::kFileSystemTypeDrive, |
| 106 base::FilePath::FromUTF8Unsafe("/special/drive/root/file1.txt"))); | 106 base::FilePath::FromUTF8Unsafe("/special/drive/root/file1.txt"))); |
| 107 urls.push_back(storage::FileSystemURL::CreateForTest( | 107 urls.push_back(storage::FileSystemURL::CreateForTest( |
| 108 GURL("http://origin/"), | 108 GURL("http://origin/"), |
| 109 storage::kFileSystemTypeDrive, | 109 storage::kFileSystemTypeDrive, |
| 110 base::FilePath::FromUTF8Unsafe("/special/drive/root/file2.txt"))); | 110 base::FilePath::FromUTF8Unsafe("/special/drive/root/file2.txt"))); |
| 111 | 111 |
| 112 extensions::api::file_browser_private::TaskResult result = | 112 extensions::api::file_manager_private::TaskResult result = |
| 113 extensions::api::file_browser_private::TASK_RESULT_NONE; | 113 extensions::api::file_manager_private::TASK_RESULT_NONE; |
| 114 executor->Execute(urls, | 114 executor->Execute(urls, |
| 115 google_apis::test_util::CreateCopyResultCallback(&result)); | 115 google_apis::test_util::CreateCopyResultCallback(&result)); |
| 116 base::RunLoop().RunUntilIdle(); | 116 base::RunLoop().RunUntilIdle(); |
| 117 | 117 |
| 118 EXPECT_EQ(extensions::api::file_browser_private::TASK_RESULT_OPENED, result); | 118 EXPECT_EQ(extensions::api::file_manager_private::TASK_RESULT_OPENED, result); |
| 119 ASSERT_EQ(2u, opend_urls.size()); | 119 ASSERT_EQ(2u, opend_urls.size()); |
| 120 EXPECT_TRUE(opend_urls.count("http://openlink/id1/test-app-id")); | 120 EXPECT_TRUE(opend_urls.count("http://openlink/id1/test-app-id")); |
| 121 EXPECT_TRUE(opend_urls.count("http://openlink/id2/test-app-id")); | 121 EXPECT_TRUE(opend_urls.count("http://openlink/id2/test-app-id")); |
| 122 } | 122 } |
| 123 | 123 |
| 124 TEST(FileTaskExecutorTest, DriveAppOpenFailForNonExistingFile) { | 124 TEST(FileTaskExecutorTest, DriveAppOpenFailForNonExistingFile) { |
| 125 content::TestBrowserThreadBundle thread_bundle; | 125 content::TestBrowserThreadBundle thread_bundle; |
| 126 | 126 |
| 127 std::set<std::string> opend_urls; | 127 std::set<std::string> opend_urls; |
| 128 | 128 |
| 129 // |delegate_ptr| will be owned by |executor|. | 129 // |delegate_ptr| will be owned by |executor|. |
| 130 TestDelegate* const delegate_ptr = new TestDelegate(&opend_urls); | 130 TestDelegate* const delegate_ptr = new TestDelegate(&opend_urls); |
| 131 ASSERT_TRUE(delegate_ptr->SetUpTestFiles()); | 131 ASSERT_TRUE(delegate_ptr->SetUpTestFiles()); |
| 132 // |executor| deletes itself after Execute() is finished. | 132 // |executor| deletes itself after Execute() is finished. |
| 133 FileTaskExecutor* const executor = new FileTaskExecutor( | 133 FileTaskExecutor* const executor = new FileTaskExecutor( |
| 134 scoped_ptr<FileTaskExecutorDelegate>(delegate_ptr), "test-app-id"); | 134 scoped_ptr<FileTaskExecutorDelegate>(delegate_ptr), "test-app-id"); |
| 135 | 135 |
| 136 std::vector<storage::FileSystemURL> urls; | 136 std::vector<storage::FileSystemURL> urls; |
| 137 urls.push_back(storage::FileSystemURL::CreateForTest( | 137 urls.push_back(storage::FileSystemURL::CreateForTest( |
| 138 GURL("http://origin/"), | 138 GURL("http://origin/"), |
| 139 storage::kFileSystemTypeDrive, | 139 storage::kFileSystemTypeDrive, |
| 140 base::FilePath::FromUTF8Unsafe("/special/drive/root/not-exist.txt"))); | 140 base::FilePath::FromUTF8Unsafe("/special/drive/root/not-exist.txt"))); |
| 141 | 141 |
| 142 extensions::api::file_browser_private::TaskResult result = | 142 extensions::api::file_manager_private::TaskResult result = |
| 143 extensions::api::file_browser_private::TASK_RESULT_NONE; | 143 extensions::api::file_manager_private::TASK_RESULT_NONE; |
| 144 executor->Execute(urls, | 144 executor->Execute(urls, |
| 145 google_apis::test_util::CreateCopyResultCallback(&result)); | 145 google_apis::test_util::CreateCopyResultCallback(&result)); |
| 146 base::RunLoop().RunUntilIdle(); | 146 base::RunLoop().RunUntilIdle(); |
| 147 | 147 |
| 148 EXPECT_EQ(extensions::api::file_browser_private::TASK_RESULT_FAILED, result); | 148 EXPECT_EQ(extensions::api::file_manager_private::TASK_RESULT_FAILED, result); |
| 149 ASSERT_TRUE(opend_urls.empty()); | 149 ASSERT_TRUE(opend_urls.empty()); |
| 150 } | 150 } |
| 151 | 151 |
| 152 } // namespace drive | 152 } // namespace drive |
| OLD | NEW |