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

Side by Side Diff: chrome/browser/chromeos/file_manager/file_tasks_unittest.cc

Issue 23740004: Files.app: Let the file browser private tasks APIs use the auto-generated helper classes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed the test. Created 7 years, 3 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 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 <utility> 8 #include <utility>
9 9
10 #include "base/prefs/pref_registry_simple.h" 10 #include "base/prefs/pref_registry_simple.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 TEST(FileManagerFileTasksTest, 49 TEST(FileManagerFileTasksTest,
50 FullTaskDescriptor_NonDriveAppWithIconAndDefault) { 50 FullTaskDescriptor_NonDriveAppWithIconAndDefault) {
51 FullTaskDescriptor full_descriptor( 51 FullTaskDescriptor full_descriptor(
52 TaskDescriptor("app-id", 52 TaskDescriptor("app-id",
53 TASK_TYPE_FILE_BROWSER_HANDLER, 53 TASK_TYPE_FILE_BROWSER_HANDLER,
54 "action-id"), 54 "action-id"),
55 "task title", 55 "task title",
56 GURL("http://example.com/icon.png"), 56 GURL("http://example.com/icon.png"),
57 true /* is_default */); 57 true /* is_default */);
58 58
59 scoped_ptr<base::DictionaryValue> dictionary( 59 const std::string task_id =
60 full_descriptor.AsDictionaryValue()); 60 TaskDescriptorToId(full_descriptor.task_descriptor());
61 std::string task_id;
62 EXPECT_TRUE(dictionary->GetString("taskId", &task_id));
63 EXPECT_EQ("app-id|file|action-id", task_id); 61 EXPECT_EQ("app-id|file|action-id", task_id);
64 62 EXPECT_EQ("http://example.com/icon.png", full_descriptor.icon_url().spec());
65 std::string icon_url; 63 EXPECT_EQ("task title", full_descriptor.task_title());
66 EXPECT_TRUE(dictionary->GetString("iconUrl", &icon_url)); 64 EXPECT_TRUE(full_descriptor.is_default());
67 EXPECT_EQ("http://example.com/icon.png", icon_url);
68
69 std::string title;
70 EXPECT_TRUE(dictionary->GetString("title", &title));
71 EXPECT_EQ("task title", title);
72
73 bool is_default = false;
74 EXPECT_TRUE(dictionary->GetBoolean("isDefault", &is_default));
75 EXPECT_TRUE(is_default);
76 } 65 }
77 66
78 TEST(FileManagerFileTasksTest, 67 TEST(FileManagerFileTasksTest,
79 FullTaskDescriptor_DriveAppWithoutIconAndNotDefault) { 68 FullTaskDescriptor_DriveAppWithoutIconAndNotDefault) {
80 FullTaskDescriptor full_descriptor( 69 FullTaskDescriptor full_descriptor(
81 TaskDescriptor("app-id", 70 TaskDescriptor("app-id",
82 TASK_TYPE_DRIVE_APP, 71 TASK_TYPE_DRIVE_APP,
83 "action-id"), 72 "action-id"),
84 "task title", 73 "task title",
85 GURL(), // No icon URL. 74 GURL(), // No icon URL.
86 false /* is_default */); 75 false /* is_default */);
87 76
88 scoped_ptr<base::DictionaryValue> dictionary( 77 const std::string task_id =
89 full_descriptor.AsDictionaryValue()); 78 TaskDescriptorToId(full_descriptor.task_descriptor());
90 std::string task_id;
91 EXPECT_TRUE(dictionary->GetString("taskId", &task_id));
92 EXPECT_EQ("app-id|drive|action-id", task_id); 79 EXPECT_EQ("app-id|drive|action-id", task_id);
93 80 EXPECT_TRUE(full_descriptor.icon_url().is_empty());
94 std::string icon_url; 81 EXPECT_EQ("task title", full_descriptor.task_title());
95 EXPECT_FALSE(dictionary->GetString("iconUrl", &icon_url)); 82 EXPECT_FALSE(full_descriptor.is_default());
96
97 std::string title;
98 EXPECT_TRUE(dictionary->GetString("title", &title));
99 EXPECT_EQ("task title", title);
100
101 bool is_default = false;
102 EXPECT_TRUE(dictionary->GetBoolean("isDefault", &is_default));
103 EXPECT_FALSE(is_default);
104 } 83 }
105 84
106 TEST(FileManagerFileTasksTest, MakeTaskID) { 85 TEST(FileManagerFileTasksTest, MakeTaskID) {
107 EXPECT_EQ("app-id|file|action-id", 86 EXPECT_EQ("app-id|file|action-id",
108 MakeTaskID("app-id", TASK_TYPE_FILE_BROWSER_HANDLER, "action-id")); 87 MakeTaskID("app-id", TASK_TYPE_FILE_BROWSER_HANDLER, "action-id"));
109 EXPECT_EQ("app-id|app|action-id", 88 EXPECT_EQ("app-id|app|action-id",
110 MakeTaskID("app-id", TASK_TYPE_FILE_HANDLER, "action-id")); 89 MakeTaskID("app-id", TASK_TYPE_FILE_HANDLER, "action-id"));
111 EXPECT_EQ("app-id|drive|action-id", 90 EXPECT_EQ("app-id|drive|action-id",
112 MakeTaskID("app-id", TASK_TYPE_DRIVE_APP, "action-id")); 91 MakeTaskID("app-id", TASK_TYPE_DRIVE_APP, "action-id"));
113 } 92 }
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 "text/plain")); 335 "text/plain"));
357 336
358 // The internal file browser handler should be chosen as default, as it's a 337 // The internal file browser handler should be chosen as default, as it's a
359 // fallback file browser handler. 338 // fallback file browser handler.
360 ChooseAndSetDefaultTask(pref_service, path_mime_set, &tasks); 339 ChooseAndSetDefaultTask(pref_service, path_mime_set, &tasks);
361 EXPECT_TRUE(tasks[0].is_default()); 340 EXPECT_TRUE(tasks[0].is_default());
362 } 341 }
363 342
364 } // namespace file_tasks 343 } // namespace file_tasks
365 } // namespace file_manager. 344 } // namespace file_manager.
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/file_manager/file_tasks.cc ('k') | chrome/common/extensions/api/file_browser_private.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698