| 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 |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/strings/utf_string_conversions.h" |
| 12 #include "base/values.h" | 13 #include "base/values.h" |
| 13 #include "chrome/browser/chromeos/drive/file_system_util.h" | 14 #include "chrome/browser/chromeos/drive/file_system_util.h" |
| 14 #include "chrome/browser/chromeos/file_manager/app_id.h" | 15 #include "chrome/browser/chromeos/file_manager/app_id.h" |
| 15 #include "chrome/browser/chromeos/login/users/scoped_test_user_manager.h" | 16 #include "chrome/browser/chromeos/login/users/scoped_test_user_manager.h" |
| 16 #include "chrome/browser/chromeos/settings/cros_settings.h" | 17 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 17 #include "chrome/browser/chromeos/settings/device_settings_service.h" | 18 #include "chrome/browser/chromeos/settings/device_settings_service.h" |
| 18 #include "chrome/browser/extensions/extension_service.h" | 19 #include "chrome/browser/extensions/extension_service.h" |
| 19 #include "chrome/browser/extensions/test_extension_system.h" | 20 #include "chrome/browser/extensions/test_extension_system.h" |
| 20 #include "chrome/common/pref_names.h" | 21 #include "chrome/common/pref_names.h" |
| 21 #include "chrome/test/base/testing_profile.h" | 22 #include "chrome/test/base/testing_profile.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 | 56 |
| 56 pref_service->Set(prefs::kDefaultTasksByMimeType, mime_types); | 57 pref_service->Set(prefs::kDefaultTasksByMimeType, mime_types); |
| 57 pref_service->Set(prefs::kDefaultTasksBySuffix, suffixes); | 58 pref_service->Set(prefs::kDefaultTasksBySuffix, suffixes); |
| 58 } | 59 } |
| 59 | 60 |
| 60 } // namespace | 61 } // namespace |
| 61 | 62 |
| 62 TEST(FileManagerFileTasksTest, | 63 TEST(FileManagerFileTasksTest, |
| 63 FullTaskDescriptor_NonDriveAppWithIconAndDefault) { | 64 FullTaskDescriptor_NonDriveAppWithIconAndDefault) { |
| 64 FullTaskDescriptor full_descriptor( | 65 FullTaskDescriptor full_descriptor( |
| 65 TaskDescriptor("app-id", | 66 TaskDescriptor("app-id", TASK_TYPE_FILE_BROWSER_HANDLER, "action-id"), |
| 66 TASK_TYPE_FILE_BROWSER_HANDLER, | 67 base::UTF8ToUTF16("task title"), GURL("http://example.com/icon.png"), |
| 67 "action-id"), | 68 true /* is_default */, false /* is_generic_file_handler */); |
| 68 "task title", | |
| 69 GURL("http://example.com/icon.png"), | |
| 70 true /* is_default */, | |
| 71 false /* is_generic_file_handler */); | |
| 72 | 69 |
| 73 const std::string task_id = | 70 const std::string task_id = |
| 74 TaskDescriptorToId(full_descriptor.task_descriptor()); | 71 TaskDescriptorToId(full_descriptor.task_descriptor()); |
| 75 EXPECT_EQ("app-id|file|action-id", task_id); | 72 EXPECT_EQ("app-id|file|action-id", task_id); |
| 76 EXPECT_EQ("http://example.com/icon.png", full_descriptor.icon_url().spec()); | 73 EXPECT_EQ("http://example.com/icon.png", full_descriptor.icon_url().spec()); |
| 77 EXPECT_EQ("task title", full_descriptor.task_title()); | 74 EXPECT_EQ(base::UTF8ToUTF16("task title"), full_descriptor.task_title()); |
| 78 EXPECT_TRUE(full_descriptor.is_default()); | 75 EXPECT_TRUE(full_descriptor.is_default()); |
| 79 } | 76 } |
| 80 | 77 |
| 81 TEST(FileManagerFileTasksTest, | 78 TEST(FileManagerFileTasksTest, |
| 82 FullTaskDescriptor_DriveAppWithoutIconAndNotDefault) { | 79 FullTaskDescriptor_DriveAppWithoutIconAndNotDefault) { |
| 83 FullTaskDescriptor full_descriptor( | 80 FullTaskDescriptor full_descriptor( |
| 84 TaskDescriptor("app-id", | 81 TaskDescriptor("app-id", TASK_TYPE_DRIVE_APP, "action-id"), |
| 85 TASK_TYPE_DRIVE_APP, | 82 base::UTF8ToUTF16("task title"), |
| 86 "action-id"), | |
| 87 "task title", | |
| 88 GURL(), // No icon URL. | 83 GURL(), // No icon URL. |
| 89 false /* is_default */, | 84 false /* is_default */, false /* is_generic_file_handler */); |
| 90 false /* is_generic_file_handler */); | |
| 91 | 85 |
| 92 const std::string task_id = | 86 const std::string task_id = |
| 93 TaskDescriptorToId(full_descriptor.task_descriptor()); | 87 TaskDescriptorToId(full_descriptor.task_descriptor()); |
| 94 EXPECT_EQ("app-id|drive|action-id", task_id); | 88 EXPECT_EQ("app-id|drive|action-id", task_id); |
| 95 EXPECT_TRUE(full_descriptor.icon_url().is_empty()); | 89 EXPECT_TRUE(full_descriptor.icon_url().is_empty()); |
| 96 EXPECT_EQ("task title", full_descriptor.task_title()); | 90 EXPECT_EQ(base::UTF8ToUTF16("task title"), full_descriptor.task_title()); |
| 97 EXPECT_FALSE(full_descriptor.is_default()); | 91 EXPECT_FALSE(full_descriptor.is_default()); |
| 98 } | 92 } |
| 99 | 93 |
| 100 TEST(FileManagerFileTasksTest, MakeTaskID) { | 94 TEST(FileManagerFileTasksTest, MakeTaskID) { |
| 101 EXPECT_EQ("app-id|file|action-id", | 95 EXPECT_EQ("app-id|file|action-id", |
| 102 MakeTaskID("app-id", TASK_TYPE_FILE_BROWSER_HANDLER, "action-id")); | 96 MakeTaskID("app-id", TASK_TYPE_FILE_BROWSER_HANDLER, "action-id")); |
| 103 EXPECT_EQ("app-id|app|action-id", | 97 EXPECT_EQ("app-id|app|action-id", |
| 104 MakeTaskID("app-id", TASK_TYPE_FILE_HANDLER, "action-id")); | 98 MakeTaskID("app-id", TASK_TYPE_FILE_HANDLER, "action-id")); |
| 105 EXPECT_EQ("app-id|drive|action-id", | 99 EXPECT_EQ("app-id|drive|action-id", |
| 106 MakeTaskID("app-id", TASK_TYPE_DRIVE_APP, "action-id")); | 100 MakeTaskID("app-id", TASK_TYPE_DRIVE_APP, "action-id")); |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 | 245 |
| 252 // Text.app and Nice.app were found for "foo.txt". | 246 // Text.app and Nice.app were found for "foo.txt". |
| 253 TaskDescriptor text_app_task("text-app-id", | 247 TaskDescriptor text_app_task("text-app-id", |
| 254 TASK_TYPE_FILE_HANDLER, | 248 TASK_TYPE_FILE_HANDLER, |
| 255 "action-id"); | 249 "action-id"); |
| 256 TaskDescriptor nice_app_task("nice-app-id", | 250 TaskDescriptor nice_app_task("nice-app-id", |
| 257 TASK_TYPE_FILE_HANDLER, | 251 TASK_TYPE_FILE_HANDLER, |
| 258 "action-id"); | 252 "action-id"); |
| 259 std::vector<FullTaskDescriptor> tasks; | 253 std::vector<FullTaskDescriptor> tasks; |
| 260 tasks.push_back(FullTaskDescriptor( | 254 tasks.push_back(FullTaskDescriptor( |
| 261 text_app_task, | 255 text_app_task, base::UTF8ToUTF16("Text.app"), |
| 262 "Text.app", | 256 GURL("http://example.com/text_app.png"), false /* is_default */, |
| 263 GURL("http://example.com/text_app.png"), | |
| 264 false /* is_default */, | |
| 265 false /* is_generic_file_handler */)); | 257 false /* is_generic_file_handler */)); |
| 266 tasks.push_back(FullTaskDescriptor( | 258 tasks.push_back(FullTaskDescriptor( |
| 267 nice_app_task, | 259 nice_app_task, base::UTF8ToUTF16("Nice.app"), |
| 268 "Nice.app", | 260 GURL("http://example.com/nice_app.png"), false /* is_default */, |
| 269 GURL("http://example.com/nice_app.png"), | |
| 270 false /* is_default */, | |
| 271 false /* is_generic_file_handler */)); | 261 false /* is_generic_file_handler */)); |
| 272 std::vector<extensions::EntryInfo> entries; | 262 std::vector<extensions::EntryInfo> entries; |
| 273 entries.push_back(extensions::EntryInfo( | 263 entries.push_back(extensions::EntryInfo( |
| 274 base::FilePath::FromUTF8Unsafe("foo.txt"), "text/plain", false)); | 264 base::FilePath::FromUTF8Unsafe("foo.txt"), "text/plain", false)); |
| 275 | 265 |
| 276 // None of them should be chosen as default, as nothing is set in the | 266 // None of them should be chosen as default, as nothing is set in the |
| 277 // preferences. | 267 // preferences. |
| 278 ChooseAndSetDefaultTask(pref_service, entries, &tasks); | 268 ChooseAndSetDefaultTask(pref_service, entries, &tasks); |
| 279 EXPECT_FALSE(tasks[0].is_default()); | 269 EXPECT_FALSE(tasks[0].is_default()); |
| 280 EXPECT_FALSE(tasks[1].is_default()); | 270 EXPECT_FALSE(tasks[1].is_default()); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 TEST(FileManagerFileTasksTest, ChooseAndSetDefaultTask_FallbackFileBrowser) { | 309 TEST(FileManagerFileTasksTest, ChooseAndSetDefaultTask_FallbackFileBrowser) { |
| 320 TestingPrefServiceSimple pref_service; | 310 TestingPrefServiceSimple pref_service; |
| 321 RegisterDefaultTaskPreferences(&pref_service); | 311 RegisterDefaultTaskPreferences(&pref_service); |
| 322 | 312 |
| 323 // Files.app's internal file browser handler was found for "foo.txt". | 313 // Files.app's internal file browser handler was found for "foo.txt". |
| 324 TaskDescriptor files_app_task(kFileManagerAppId, | 314 TaskDescriptor files_app_task(kFileManagerAppId, |
| 325 TASK_TYPE_FILE_BROWSER_HANDLER, | 315 TASK_TYPE_FILE_BROWSER_HANDLER, |
| 326 "view-in-browser"); | 316 "view-in-browser"); |
| 327 std::vector<FullTaskDescriptor> tasks; | 317 std::vector<FullTaskDescriptor> tasks; |
| 328 tasks.push_back(FullTaskDescriptor( | 318 tasks.push_back(FullTaskDescriptor( |
| 329 files_app_task, | 319 files_app_task, base::UTF8ToUTF16("View in browser"), |
| 330 "View in browser", | 320 GURL("http://example.com/some_icon.png"), false /* is_default */, |
| 331 GURL("http://example.com/some_icon.png"), | |
| 332 false /* is_default */, | |
| 333 false /* is_generic_file_handler */)); | 321 false /* is_generic_file_handler */)); |
| 334 std::vector<extensions::EntryInfo> entries; | 322 std::vector<extensions::EntryInfo> entries; |
| 335 entries.push_back(extensions::EntryInfo( | 323 entries.push_back(extensions::EntryInfo( |
| 336 base::FilePath::FromUTF8Unsafe("foo.txt"), "text/plain", false)); | 324 base::FilePath::FromUTF8Unsafe("foo.txt"), "text/plain", false)); |
| 337 | 325 |
| 338 // The internal file browser handler should be chosen as default, as it's a | 326 // The internal file browser handler should be chosen as default, as it's a |
| 339 // fallback file browser handler. | 327 // fallback file browser handler. |
| 340 ChooseAndSetDefaultTask(pref_service, entries, &tasks); | 328 ChooseAndSetDefaultTask(pref_service, entries, &tasks); |
| 341 EXPECT_TRUE(tasks[0].is_default()); | 329 EXPECT_TRUE(tasks[0].is_default()); |
| 342 } | 330 } |
| (...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 973 // Test case with .txt file | 961 // Test case with .txt file |
| 974 std::vector<extensions::EntryInfo> txt_entries; | 962 std::vector<extensions::EntryInfo> txt_entries; |
| 975 txt_entries.push_back( | 963 txt_entries.push_back( |
| 976 extensions::EntryInfo(drive::util::GetDriveMountPointPath(&test_profile_) | 964 extensions::EntryInfo(drive::util::GetDriveMountPointPath(&test_profile_) |
| 977 .AppendASCII("foo.txt"), | 965 .AppendASCII("foo.txt"), |
| 978 "text/plain", false)); | 966 "text/plain", false)); |
| 979 std::vector<FullTaskDescriptor> txt_result; | 967 std::vector<FullTaskDescriptor> txt_result; |
| 980 FindFileHandlerTasks(&test_profile_, txt_entries, &txt_result); | 968 FindFileHandlerTasks(&test_profile_, txt_entries, &txt_result); |
| 981 EXPECT_EQ(4U, txt_result.size()); | 969 EXPECT_EQ(4U, txt_result.size()); |
| 982 // Foo app provides a handler for text/plain. | 970 // Foo app provides a handler for text/plain. |
| 983 EXPECT_EQ("Foo", txt_result[0].task_title()); | 971 EXPECT_EQ(base::UTF8ToUTF16("Open with Foo"), txt_result[0].task_title()); |
| 984 EXPECT_FALSE(txt_result[0].is_generic_file_handler()); | 972 EXPECT_FALSE(txt_result[0].is_generic_file_handler()); |
| 985 // Bar app provides a handler for .txt. | 973 // Bar app provides a handler for .txt. |
| 986 EXPECT_EQ("Bar", txt_result[1].task_title()); | 974 EXPECT_EQ(base::UTF8ToUTF16("Open with Bar"), txt_result[1].task_title()); |
| 987 EXPECT_FALSE(txt_result[1].is_generic_file_handler()); | 975 EXPECT_FALSE(txt_result[1].is_generic_file_handler()); |
| 988 // Baz app provides a handler for all extensions. | 976 // Baz app provides a handler for all extensions. |
| 989 EXPECT_EQ("Baz", txt_result[2].task_title()); | 977 EXPECT_EQ(base::UTF8ToUTF16("Open with Baz"), txt_result[2].task_title()); |
| 990 EXPECT_TRUE(txt_result[2].is_generic_file_handler()); | 978 EXPECT_TRUE(txt_result[2].is_generic_file_handler()); |
| 991 // Qux app provides a handler for all types. | 979 // Qux app provides a handler for all types. |
| 992 EXPECT_EQ("Qux", txt_result[3].task_title()); | 980 EXPECT_EQ(base::UTF8ToUTF16("Open with Qux"), txt_result[3].task_title()); |
| 993 EXPECT_TRUE(txt_result[3].is_generic_file_handler()); | 981 EXPECT_TRUE(txt_result[3].is_generic_file_handler()); |
| 994 | 982 |
| 995 // Test case with .jpg file | 983 // Test case with .jpg file |
| 996 std::vector<extensions::EntryInfo> jpg_entries; | 984 std::vector<extensions::EntryInfo> jpg_entries; |
| 997 jpg_entries.push_back( | 985 jpg_entries.push_back( |
| 998 extensions::EntryInfo(drive::util::GetDriveMountPointPath(&test_profile_) | 986 extensions::EntryInfo(drive::util::GetDriveMountPointPath(&test_profile_) |
| 999 .AppendASCII("foo.jpg"), | 987 .AppendASCII("foo.jpg"), |
| 1000 "image/jpeg", false)); | 988 "image/jpeg", false)); |
| 1001 std::vector<FullTaskDescriptor> jpg_result; | 989 std::vector<FullTaskDescriptor> jpg_result; |
| 1002 FindFileHandlerTasks(&test_profile_, jpg_entries, &jpg_result); | 990 FindFileHandlerTasks(&test_profile_, jpg_entries, &jpg_result); |
| 1003 EXPECT_EQ(3U, jpg_result.size()); | 991 EXPECT_EQ(3U, jpg_result.size()); |
| 1004 // Foo app provides a handler for all types. | 992 // Foo app provides a handler for all types. |
| 1005 EXPECT_EQ("Foo", jpg_result[0].task_title()); | 993 EXPECT_EQ(base::UTF8ToUTF16("Open with Foo"), txt_result[0].task_title()); |
| 1006 EXPECT_TRUE(jpg_result[0].is_generic_file_handler()); | 994 EXPECT_TRUE(jpg_result[0].is_generic_file_handler()); |
| 1007 // Baz app provides a handler for image/*. A partial wildcarded handler is | 995 // Baz app provides a handler for image/*. A partial wildcarded handler is |
| 1008 // treated as non-generic handler. | 996 // treated as non-generic handler. |
| 1009 EXPECT_EQ("Baz", jpg_result[1].task_title()); | 997 EXPECT_EQ(base::UTF8ToUTF16("Open with Baz"), jpg_result[1].task_title()); |
| 1010 EXPECT_FALSE(jpg_result[1].is_generic_file_handler()); | 998 EXPECT_FALSE(jpg_result[1].is_generic_file_handler()); |
| 1011 // Qux app provides a handler for all types. | 999 // Qux app provides a handler for all types. |
| 1012 EXPECT_EQ("Qux", jpg_result[2].task_title()); | 1000 EXPECT_EQ(base::UTF8ToUTF16("Open with Qux"), jpg_result[2].task_title()); |
| 1013 EXPECT_TRUE(jpg_result[2].is_generic_file_handler()); | 1001 EXPECT_TRUE(jpg_result[2].is_generic_file_handler()); |
| 1014 | 1002 |
| 1015 // Test case with directories. | 1003 // Test case with directories. |
| 1016 std::vector<extensions::EntryInfo> dir_entries; | 1004 std::vector<extensions::EntryInfo> dir_entries; |
| 1017 dir_entries.push_back(extensions::EntryInfo( | 1005 dir_entries.push_back(extensions::EntryInfo( |
| 1018 drive::util::GetDriveMountPointPath(&test_profile_).AppendASCII("dir"), | 1006 drive::util::GetDriveMountPointPath(&test_profile_).AppendASCII("dir"), |
| 1019 "", true)); | 1007 "", true)); |
| 1020 std::vector<FullTaskDescriptor> dir_result; | 1008 std::vector<FullTaskDescriptor> dir_result; |
| 1021 FindFileHandlerTasks(&test_profile_, dir_entries, &dir_result); | 1009 FindFileHandlerTasks(&test_profile_, dir_entries, &dir_result); |
| 1022 ASSERT_EQ(1U, dir_result.size()); | 1010 ASSERT_EQ(1U, dir_result.size()); |
| 1023 // Confirm that only Bar.app is found and that it is a generic file handler. | 1011 // 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); | 1012 EXPECT_EQ(kBarId, dir_result[0].task_descriptor().app_id); |
| 1025 EXPECT_TRUE(dir_result[0].is_generic_file_handler()); | 1013 EXPECT_TRUE(dir_result[0].is_generic_file_handler()); |
| 1026 } | 1014 } |
| 1027 | 1015 |
| 1016 // The basic logic is similar to a test case for FindDriveAppTasks above. |
| 1017 TEST_F(FileManagerFileTasksComplexTest, FindFileHandlerTask_Verbs) { |
| 1018 // kFooId copied from FindFileHandlerTasks test above. |
| 1019 const char kFooId[] = "hhgbjpmdppecanaaogonaigmmifgpaph"; |
| 1020 |
| 1021 // Foo.app can handle "text/plain" and "text/html". |
| 1022 extensions::ExtensionBuilder foo_app; |
| 1023 foo_app.SetManifest( |
| 1024 extensions::DictionaryBuilder() |
| 1025 .Set("name", "Foo") |
| 1026 .Set("version", "1.0.0") |
| 1027 .Set("manifest_version", 2) |
| 1028 .Set("app", extensions::DictionaryBuilder() |
| 1029 .Set("background", |
| 1030 extensions::DictionaryBuilder() |
| 1031 .Set("scripts", extensions::ListBuilder() |
| 1032 .Append("background.js") |
| 1033 .Build()) |
| 1034 .Build()) |
| 1035 .Build()) |
| 1036 .Set( |
| 1037 "file_handlers", |
| 1038 extensions::DictionaryBuilder() |
| 1039 .Set("any", |
| 1040 extensions::DictionaryBuilder() |
| 1041 .Set("types", |
| 1042 extensions::ListBuilder().Append("*").Build()) |
| 1043 .Set("verb", "ADD_TO") |
| 1044 .Build()) |
| 1045 .Set("any_with_directories", |
| 1046 extensions::DictionaryBuilder() |
| 1047 .SetBoolean("include_directories", true) |
| 1048 .Set("types", |
| 1049 extensions::ListBuilder().Append("*").Build()) |
| 1050 .Set("verb", "PACK_WITH") |
| 1051 .Build()) |
| 1052 .Set("all_text", extensions::DictionaryBuilder() |
| 1053 .Set("title", "Text") |
| 1054 .Set("types", extensions::ListBuilder() |
| 1055 .Append("text/plain") |
| 1056 .Append("text/html") |
| 1057 .Build()) |
| 1058 .Set("verb", "ADD_TO") |
| 1059 .Build()) |
| 1060 .Set("plain_text", extensions::DictionaryBuilder() |
| 1061 .Set("title", "Plain") |
| 1062 .Set("types", extensions::ListBuilder() |
| 1063 .Append("text/plain") |
| 1064 .Build()) |
| 1065 .Set("verb", "OPEN_WITH") |
| 1066 .Build()) |
| 1067 .Set("html_text_duplicate_verb", |
| 1068 extensions::DictionaryBuilder() |
| 1069 .Set("title", "Html") |
| 1070 .Set("types", extensions::ListBuilder() |
| 1071 .Append("text/html") |
| 1072 .Build()) |
| 1073 .Set("verb", "ADD_TO") |
| 1074 .Build()) |
| 1075 .Build()) |
| 1076 .Build()); |
| 1077 foo_app.SetID(kFooId); |
| 1078 extension_service_->AddExtension(foo_app.Build().get()); |
| 1079 |
| 1080 // Find app with corresponding verbs for a "text/plain" file. |
| 1081 // Foo.app with ADD_TO, OPEN_WITH and PACK_WITH should be found, but only |
| 1082 // one ADD_TO that is not a generic handler will be taken into account, |
| 1083 // even though there are 2 ADD_TO matches for "text/plain". |
| 1084 std::vector<extensions::EntryInfo> entries; |
| 1085 entries.push_back( |
| 1086 extensions::EntryInfo(drive::util::GetDriveMountPointPath(&test_profile_) |
| 1087 .AppendASCII("foo.txt"), |
| 1088 "text/plain", false)); |
| 1089 |
| 1090 std::vector<FullTaskDescriptor> tasks; |
| 1091 FindFileHandlerTasks(&test_profile_, entries, &tasks); |
| 1092 |
| 1093 ASSERT_EQ(3U, tasks.size()); |
| 1094 EXPECT_EQ(kFooId, tasks[0].task_descriptor().app_id); |
| 1095 EXPECT_EQ(base::UTF8ToUTF16("Add to Foo"), tasks[0].task_title()); |
| 1096 EXPECT_EQ(kFooId, tasks[1].task_descriptor().app_id); |
| 1097 EXPECT_EQ(base::UTF8ToUTF16("Open with Foo"), tasks[1].task_title()); |
| 1098 EXPECT_EQ(kFooId, tasks[2].task_descriptor().app_id); |
| 1099 EXPECT_EQ(base::UTF8ToUTF16("Pack with Foo"), tasks[2].task_title()); |
| 1100 |
| 1101 // Find app with corresponding verbs for a "text/html" file. |
| 1102 // Foo.app with ADD_TO and PACK_WITH should be found, but only the first |
| 1103 // ADD_TO that is a good match will be taken into account, even though there |
| 1104 // are 3 ADD_TO matches for "text/html". |
| 1105 entries.clear(); |
| 1106 entries.push_back( |
| 1107 extensions::EntryInfo(drive::util::GetDriveMountPointPath(&test_profile_) |
| 1108 .AppendASCII("foo.html"), |
| 1109 "text/html", false)); |
| 1110 tasks.clear(); |
| 1111 FindFileHandlerTasks(&test_profile_, entries, &tasks); |
| 1112 |
| 1113 ASSERT_EQ(2U, tasks.size()); |
| 1114 EXPECT_EQ(kFooId, tasks[0].task_descriptor().app_id); |
| 1115 EXPECT_EQ(base::UTF8ToUTF16("Add to Foo"), tasks[0].task_title()); |
| 1116 EXPECT_EQ(kFooId, tasks[1].task_descriptor().app_id); |
| 1117 EXPECT_EQ(base::UTF8ToUTF16("Pack with Foo"), tasks[1].task_title()); |
| 1118 |
| 1119 // Find app with corresponding verbs for directories. |
| 1120 // Foo.app with only PACK_WITH should be found. |
| 1121 entries.clear(); |
| 1122 entries.push_back(extensions::EntryInfo( |
| 1123 drive::util::GetDriveMountPointPath(&test_profile_).AppendASCII("dir"), |
| 1124 "", true)); |
| 1125 tasks.clear(); |
| 1126 FindFileHandlerTasks(&test_profile_, entries, &tasks); |
| 1127 |
| 1128 ASSERT_EQ(1U, tasks.size()); |
| 1129 EXPECT_EQ(kFooId, tasks[0].task_descriptor().app_id); |
| 1130 EXPECT_EQ(base::UTF8ToUTF16("Pack with Foo"), tasks[0].task_title()); |
| 1131 } |
| 1132 |
| 1028 } // namespace file_tasks | 1133 } // namespace file_tasks |
| 1029 } // namespace file_manager. | 1134 } // namespace file_manager. |
| OLD | NEW |