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 3 // found in the LICENSE file. 4 5 #include "chrome/browser/chromeos/extensions/file_manager/file_tasks.h" 6 7 #include "testing/gtest/include/gtest/gtest.h" 8 9 namespace file_manager { 10 namespace file_tasks { 11 12 TEST(FileManagerFileTasksTest, MakeTaskID) { 13 EXPECT_EQ("app-id|app|action-id", MakeTaskID("app-id", "app", "action-id")); 14 } 15 16 TEST(FileManagerFileTasksTest, MakeDriveAppTaskId) { 17 EXPECT_EQ("app-id|drive|open-with", MakeDriveAppTaskId("app-id")); 18 } 19 20 TEST(FileManagerFileTasksTest, ParseTaskID_Basic) { 21 TaskDescriptor task; 22 // A task ID usually has three parts. 23 EXPECT_TRUE(ParseTaskID("app-id|app|action-id", &task)); 24 EXPECT_EQ("app-id", task.app_id); 25 EXPECT_EQ("app", task.task_type); 26 EXPECT_EQ("action-id", task.action_id); 27 } 28 29 TEST(FileManagerFileTasksTest, ParseTaskID_Legacy) { 30 TaskDescriptor task; 31 // A legacy task ID only has two parts. The task type should be to "file". 32 EXPECT_TRUE(ParseTaskID("app-id|action-id", &task)); 33 EXPECT_EQ("app-id", task.app_id); 34 EXPECT_EQ("file", task.task_type); 35 EXPECT_EQ("action-id", task.action_id); 36 } 37 38 TEST(FileManagerFileTasksTest, ParseTaskID_LegacyDrive) { 39 TaskDescriptor task; 40 // A legacy task ID only has two parts. For Drive app, the app ID is 41 // prefixed with "drive-app:". 42 EXPECT_TRUE(ParseTaskID("drive-app:app-id|action-id", &task)); 43 EXPECT_EQ("app-id", task.app_id); 44 EXPECT_EQ("drive", task.task_type); 45 EXPECT_EQ("action-id", task.action_id); 46 } 47 48 TEST(FileManagerFileTasksTest, ParseTaskID_Invalid) { 49 TaskDescriptor task; 50 EXPECT_FALSE(ParseTaskID("invalid", &task)); 51 } 52 53 } // namespace file_tasks 54 } // namespace file_manager. 55