| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/file_manager/file_tasks.h" | 5 #include "chrome/browser/chromeos/file_manager/file_tasks.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 TaskDescriptor task; | 166 TaskDescriptor task; |
| 167 EXPECT_FALSE(ParseTaskID("app-id|unknown|action-id", &task)); | 167 EXPECT_FALSE(ParseTaskID("app-id|unknown|action-id", &task)); |
| 168 } | 168 } |
| 169 | 169 |
| 170 TEST(FileManagerFileTasksTest, FindDriveAppTasks) { | 170 TEST(FileManagerFileTasksTest, FindDriveAppTasks) { |
| 171 TestingProfile profile; | 171 TestingProfile profile; |
| 172 // For DriveAppRegistry, which checks CurrentlyOn(BrowserThread::UI). | 172 // For DriveAppRegistry, which checks CurrentlyOn(BrowserThread::UI). |
| 173 content::TestBrowserThreadBundle thread_bundle; | 173 content::TestBrowserThreadBundle thread_bundle; |
| 174 | 174 |
| 175 // Foo.app can handle "text/plain" and "text/html" | 175 // Foo.app can handle "text/plain" and "text/html" |
| 176 scoped_ptr<google_apis::AppResource> foo_app(new google_apis::AppResource); | 176 std::unique_ptr<google_apis::AppResource> foo_app( |
| 177 new google_apis::AppResource); |
| 177 foo_app->set_product_id("foo_app_id"); | 178 foo_app->set_product_id("foo_app_id"); |
| 178 foo_app->set_application_id("foo_app_id"); | 179 foo_app->set_application_id("foo_app_id"); |
| 179 foo_app->set_name("Foo"); | 180 foo_app->set_name("Foo"); |
| 180 foo_app->set_object_type("foo_object_type"); | 181 foo_app->set_object_type("foo_object_type"); |
| 181 ScopedVector<std::string> foo_mime_types; | 182 ScopedVector<std::string> foo_mime_types; |
| 182 foo_mime_types.push_back(new std::string("text/plain")); | 183 foo_mime_types.push_back(new std::string("text/plain")); |
| 183 foo_mime_types.push_back(new std::string("text/html")); | 184 foo_mime_types.push_back(new std::string("text/html")); |
| 184 foo_app->set_primary_mimetypes(std::move(foo_mime_types)); | 185 foo_app->set_primary_mimetypes(std::move(foo_mime_types)); |
| 185 | 186 |
| 186 // Bar.app can only handle "text/plain". | 187 // Bar.app can only handle "text/plain". |
| 187 scoped_ptr<google_apis::AppResource> bar_app(new google_apis::AppResource); | 188 std::unique_ptr<google_apis::AppResource> bar_app( |
| 189 new google_apis::AppResource); |
| 188 bar_app->set_product_id("bar_app_id"); | 190 bar_app->set_product_id("bar_app_id"); |
| 189 bar_app->set_application_id("bar_app_id"); | 191 bar_app->set_application_id("bar_app_id"); |
| 190 bar_app->set_name("Bar"); | 192 bar_app->set_name("Bar"); |
| 191 bar_app->set_object_type("bar_object_type"); | 193 bar_app->set_object_type("bar_object_type"); |
| 192 ScopedVector<std::string> bar_mime_types; | 194 ScopedVector<std::string> bar_mime_types; |
| 193 bar_mime_types.push_back(new std::string("text/plain")); | 195 bar_mime_types.push_back(new std::string("text/plain")); |
| 194 bar_app->set_primary_mimetypes(std::move(bar_mime_types)); | 196 bar_app->set_primary_mimetypes(std::move(bar_mime_types)); |
| 195 | 197 |
| 196 // Prepare DriveAppRegistry from Foo.app and Bar.app. | 198 // Prepare DriveAppRegistry from Foo.app and Bar.app. |
| 197 ScopedVector<google_apis::AppResource> app_resources; | 199 ScopedVector<google_apis::AppResource> app_resources; |
| (...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 699 .Append("filesystem:*.txt") | 701 .Append("filesystem:*.txt") |
| 700 .Build()) | 702 .Build()) |
| 701 .Build()) | 703 .Build()) |
| 702 .Build()) | 704 .Build()) |
| 703 .Build()); | 705 .Build()); |
| 704 bar_app.SetID(kBarId); | 706 bar_app.SetID(kBarId); |
| 705 extension_service_->AddExtension(bar_app.Build().get()); | 707 extension_service_->AddExtension(bar_app.Build().get()); |
| 706 | 708 |
| 707 // Baz.app can handle "text/plain". | 709 // Baz.app can handle "text/plain". |
| 708 // This is a Drive app. | 710 // This is a Drive app. |
| 709 scoped_ptr<google_apis::AppResource> baz_app(new google_apis::AppResource); | 711 std::unique_ptr<google_apis::AppResource> baz_app( |
| 712 new google_apis::AppResource); |
| 710 baz_app->set_product_id("baz_app_id"); | 713 baz_app->set_product_id("baz_app_id"); |
| 711 baz_app->set_application_id(kBazId); | 714 baz_app->set_application_id(kBazId); |
| 712 baz_app->set_name("Baz"); | 715 baz_app->set_name("Baz"); |
| 713 baz_app->set_object_type("baz_object_type"); | 716 baz_app->set_object_type("baz_object_type"); |
| 714 ScopedVector<std::string> baz_mime_types; | 717 ScopedVector<std::string> baz_mime_types; |
| 715 baz_mime_types.push_back(new std::string("text/plain")); | 718 baz_mime_types.push_back(new std::string("text/plain")); |
| 716 baz_app->set_primary_mimetypes(std::move(baz_mime_types)); | 719 baz_app->set_primary_mimetypes(std::move(baz_mime_types)); |
| 717 // Set up DriveAppRegistry. | 720 // Set up DriveAppRegistry. |
| 718 ScopedVector<google_apis::AppResource> app_resources; | 721 ScopedVector<google_apis::AppResource> app_resources; |
| 719 app_resources.push_back(baz_app.release()); | 722 app_resources.push_back(baz_app.release()); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 747 EXPECT_EQ(kBarId, app_ids[1]); | 750 EXPECT_EQ(kBarId, app_ids[1]); |
| 748 EXPECT_EQ(kBazId, app_ids[2]); | 751 EXPECT_EQ(kBazId, app_ids[2]); |
| 749 } | 752 } |
| 750 | 753 |
| 751 TEST_F(FileManagerFileTasksComplexTest, FindAllTypesOfTasks_GoogleDocument) { | 754 TEST_F(FileManagerFileTasksComplexTest, FindAllTypesOfTasks_GoogleDocument) { |
| 752 // kFooId and kBarId copied from FindFileHandlerTasks test above. | 755 // kFooId and kBarId copied from FindFileHandlerTasks test above. |
| 753 const char kFooId[] = "hhgbjpmdppecanaaogonaigmmifgpaph"; | 756 const char kFooId[] = "hhgbjpmdppecanaaogonaigmmifgpaph"; |
| 754 const char kBarId[] = "odlhccgofgkadkkhcmhgnhgahonahoca"; | 757 const char kBarId[] = "odlhccgofgkadkkhcmhgnhgahonahoca"; |
| 755 | 758 |
| 756 // Foo.app can handle ".gdoc" files. | 759 // Foo.app can handle ".gdoc" files. |
| 757 scoped_ptr<google_apis::AppResource> foo_app(new google_apis::AppResource); | 760 std::unique_ptr<google_apis::AppResource> foo_app( |
| 761 new google_apis::AppResource); |
| 758 foo_app->set_product_id("foo_app"); | 762 foo_app->set_product_id("foo_app"); |
| 759 foo_app->set_application_id(kFooId); | 763 foo_app->set_application_id(kFooId); |
| 760 foo_app->set_name("Foo"); | 764 foo_app->set_name("Foo"); |
| 761 foo_app->set_object_type("foo_object_type"); | 765 foo_app->set_object_type("foo_object_type"); |
| 762 ScopedVector<std::string> foo_extensions; | 766 ScopedVector<std::string> foo_extensions; |
| 763 foo_extensions.push_back(new std::string("gdoc")); // Not ".gdoc" | 767 foo_extensions.push_back(new std::string("gdoc")); // Not ".gdoc" |
| 764 foo_app->set_primary_file_extensions(std::move(foo_extensions)); | 768 foo_app->set_primary_file_extensions(std::move(foo_extensions)); |
| 765 | 769 |
| 766 // Prepare DriveAppRegistry from Foo.app. | 770 // Prepare DriveAppRegistry from Foo.app. |
| 767 ScopedVector<google_apis::AppResource> app_resources; | 771 ScopedVector<google_apis::AppResource> app_resources; |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1020 std::vector<FullTaskDescriptor> dir_result; | 1024 std::vector<FullTaskDescriptor> dir_result; |
| 1021 FindFileHandlerTasks(&test_profile_, dir_entries, &dir_result); | 1025 FindFileHandlerTasks(&test_profile_, dir_entries, &dir_result); |
| 1022 ASSERT_EQ(1U, dir_result.size()); | 1026 ASSERT_EQ(1U, dir_result.size()); |
| 1023 // Confirm that only Bar.app is found and that it is a generic file handler. | 1027 // Confirm that only Bar.app is found and that it is a generic file handler. |
| 1024 EXPECT_EQ(kBarId, dir_result[0].task_descriptor().app_id); | 1028 EXPECT_EQ(kBarId, dir_result[0].task_descriptor().app_id); |
| 1025 EXPECT_TRUE(dir_result[0].is_generic_file_handler()); | 1029 EXPECT_TRUE(dir_result[0].is_generic_file_handler()); |
| 1026 } | 1030 } |
| 1027 | 1031 |
| 1028 } // namespace file_tasks | 1032 } // namespace file_tasks |
| 1029 } // namespace file_manager. | 1033 } // namespace file_manager. |
| OLD | NEW |