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

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

Issue 23532010: file_manager: Introduce FullTaskDescriptor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments 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/extensions/file_manager/file_tasks.h" 5 #include "chrome/browser/chromeos/extensions/file_manager/file_tasks.h"
6 6
7 #include "base/values.h"
7 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
8 9
9 namespace file_manager { 10 namespace file_manager {
10 namespace file_tasks { 11 namespace file_tasks {
11 12
13 TEST(FileManagerFileTasksTest,
14 FullTaskDescriptor_NonDriveAppWithIconAndDefault) {
15 FullTaskDescriptor full_descriptor(
16 TaskDescriptor("app-id",
17 TASK_TYPE_FILE_BROWSER_HANDLER,
18 "action-id"),
19 "task title",
20 GURL("http://example.com/icon.png"),
21 true /* is_default */);
22
23 scoped_ptr<base::DictionaryValue> dictionary(
24 full_descriptor.AsDictionaryValue());
25 std::string task_id;
26 EXPECT_TRUE(dictionary->GetString("taskId", &task_id));
27 EXPECT_EQ("app-id|file|action-id", task_id);
28
29 std::string icon_url;
30 EXPECT_TRUE(dictionary->GetString("iconUrl", &icon_url));
31 EXPECT_EQ("http://example.com/icon.png", icon_url);
32
33 std::string title;
34 EXPECT_TRUE(dictionary->GetString("title", &title));
35 EXPECT_EQ("task title", title);
36
37 bool is_drive_app = false;
38 EXPECT_TRUE(dictionary->GetBoolean("driveApp", &is_drive_app));
39 EXPECT_FALSE(is_drive_app);
40
41 bool is_default = false;
42 EXPECT_TRUE(dictionary->GetBoolean("isDefault", &is_default));
43 EXPECT_TRUE(is_default);
44 }
45
46 TEST(FileManagerFileTasksTest,
47 FullTaskDescriptor_DriveAppWithoutIconAndNotDefault) {
48 FullTaskDescriptor full_descriptor(
49 TaskDescriptor("app-id",
50 TASK_TYPE_DRIVE_APP,
51 "action-id"),
52 "task title",
53 GURL(), // No icon URL.
54 false /* is_default */);
55
56 scoped_ptr<base::DictionaryValue> dictionary(
57 full_descriptor.AsDictionaryValue());
58 std::string task_id;
59 EXPECT_TRUE(dictionary->GetString("taskId", &task_id));
60 EXPECT_EQ("app-id|drive|action-id", task_id);
61
62 std::string icon_url;
63 EXPECT_FALSE(dictionary->GetString("iconUrl", &icon_url));
64
65 std::string title;
66 EXPECT_TRUE(dictionary->GetString("title", &title));
67 EXPECT_EQ("task title", title);
68
69 bool is_drive_app = false;
70 EXPECT_TRUE(dictionary->GetBoolean("driveApp", &is_drive_app));
71 EXPECT_TRUE(is_drive_app);
72
73 bool is_default = false;
74 EXPECT_TRUE(dictionary->GetBoolean("isDefault", &is_default));
75 EXPECT_FALSE(is_default);
76 }
77
12 TEST(FileManagerFileTasksTest, MakeTaskID) { 78 TEST(FileManagerFileTasksTest, MakeTaskID) {
13 EXPECT_EQ("app-id|file|action-id", 79 EXPECT_EQ("app-id|file|action-id",
14 MakeTaskID("app-id", TASK_TYPE_FILE_BROWSER_HANDLER, "action-id")); 80 MakeTaskID("app-id", TASK_TYPE_FILE_BROWSER_HANDLER, "action-id"));
15 EXPECT_EQ("app-id|app|action-id", 81 EXPECT_EQ("app-id|app|action-id",
16 MakeTaskID("app-id", TASK_TYPE_FILE_HANDLER, "action-id")); 82 MakeTaskID("app-id", TASK_TYPE_FILE_HANDLER, "action-id"));
17 EXPECT_EQ("app-id|drive|action-id", 83 EXPECT_EQ("app-id|drive|action-id",
18 MakeTaskID("app-id", TASK_TYPE_DRIVE_APP, "action-id")); 84 MakeTaskID("app-id", TASK_TYPE_DRIVE_APP, "action-id"));
19 } 85 }
20 86
21 TEST(FileManagerFileTasksTest, MakeDriveAppTaskId) { 87 TEST(FileManagerFileTasksTest, MakeDriveAppTaskId) {
22 EXPECT_EQ("app-id|drive|open-with", MakeDriveAppTaskId("app-id")); 88 EXPECT_EQ("app-id|drive|open-with", MakeDriveAppTaskId("app-id"));
23 } 89 }
24 90
91 TEST(FileManagerFileTasksTest, TaskDescriptorToId) {
92 EXPECT_EQ("app-id|file|action-id",
93 TaskDescriptorToId(TaskDescriptor("app-id",
94 TASK_TYPE_FILE_BROWSER_HANDLER,
95 "action-id")));
96 }
97
25 TEST(FileManagerFileTasksTest, ParseTaskID_FileBrowserHandler) { 98 TEST(FileManagerFileTasksTest, ParseTaskID_FileBrowserHandler) {
26 TaskDescriptor task; 99 TaskDescriptor task;
27 EXPECT_TRUE(ParseTaskID("app-id|file|action-id", &task)); 100 EXPECT_TRUE(ParseTaskID("app-id|file|action-id", &task));
28 EXPECT_EQ("app-id", task.app_id); 101 EXPECT_EQ("app-id", task.app_id);
29 EXPECT_EQ(TASK_TYPE_FILE_BROWSER_HANDLER, task.task_type); 102 EXPECT_EQ(TASK_TYPE_FILE_BROWSER_HANDLER, task.task_type);
30 EXPECT_EQ("action-id", task.action_id); 103 EXPECT_EQ("action-id", task.action_id);
31 } 104 }
32 105
33 TEST(FileManagerFileTasksTest, ParseTaskID_FileHandler) { 106 TEST(FileManagerFileTasksTest, ParseTaskID_FileHandler) {
34 TaskDescriptor task; 107 TaskDescriptor task;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 EXPECT_FALSE(ParseTaskID("invalid", &task)); 144 EXPECT_FALSE(ParseTaskID("invalid", &task));
72 } 145 }
73 146
74 TEST(FileManagerFileTasksTest, ParseTaskID_UnknownTaskType) { 147 TEST(FileManagerFileTasksTest, ParseTaskID_UnknownTaskType) {
75 TaskDescriptor task; 148 TaskDescriptor task;
76 EXPECT_FALSE(ParseTaskID("app-id|unknown|action-id", &task)); 149 EXPECT_FALSE(ParseTaskID("app-id|unknown|action-id", &task));
77 } 150 }
78 151
79 } // namespace file_tasks 152 } // namespace file_tasks
80 } // namespace file_manager. 153 } // namespace file_manager.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698