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

Side by Side Diff: chrome/browser/sync_file_system/drive_backend/task_dependency_manager_unittest.cc

Issue 212203003: [SyncFS] Add exclusive task support for TaskDependencyManager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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
« no previous file with comments | « chrome/browser/sync_file_system/drive_backend/task_dependency_manager.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/sync_file_system/drive_backend/task_dependency_manager. h" 5 #include "chrome/browser/sync_file_system/drive_backend/task_dependency_manager. h"
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 #define FPL(path) FILE_PATH_LITERAL(path) 10 #define FPL(path) FILE_PATH_LITERAL(path)
(...skipping 18 matching lines...) Expand all
29 29
30 void ErasePath(TaskDependencyManager* manager, 30 void ErasePath(TaskDependencyManager* manager,
31 const std::string& app_id, 31 const std::string& app_id,
32 const base::FilePath::StringType& path) { 32 const base::FilePath::StringType& path) {
33 BlockingFactor blocker; 33 BlockingFactor blocker;
34 blocker.app_id = app_id; 34 blocker.app_id = app_id;
35 blocker.paths.push_back(MakePath(path)); 35 blocker.paths.push_back(MakePath(path));
36 return manager->Erase(blocker); 36 return manager->Erase(blocker);
37 } 37 }
38 38
39 bool InsertExclusiveTask(TaskDependencyManager* manager) {
40 BlockingFactor blocker;
41 blocker.exclusive = true;
42 return manager->Insert(blocker);
43 }
44
45 void EraseExclusiveTask(TaskDependencyManager* manager) {
46 BlockingFactor blocker;
47 blocker.exclusive = true;
48 manager->Erase(blocker);
49 }
50
39 } // namespace 51 } // namespace
40 52
41 TEST(TaskDependencyManagerTest, BasicTest) { 53 TEST(TaskDependencyManagerTest, BasicTest) {
42 TaskDependencyManager manager; 54 TaskDependencyManager manager;
43 BlockingFactor blocker; 55 BlockingFactor blocker;
44 blocker.app_id = "app_id"; 56 blocker.app_id = "app_id";
45 blocker.paths.push_back(MakePath(FPL("/folder/file"))); 57 blocker.paths.push_back(MakePath(FPL("/folder/file")));
46 blocker.file_ids.push_back("file_id"); 58 blocker.file_ids.push_back("file_id");
47 blocker.tracker_ids.push_back(100); 59 blocker.tracker_ids.push_back(100);
48 60
(...skipping 23 matching lines...) Expand all
72 EXPECT_TRUE(InsertPath( 84 EXPECT_TRUE(InsertPath(
73 &manager, "another_app_id", FPL("/ancestor/parent/self"))); 85 &manager, "another_app_id", FPL("/ancestor/parent/self")));
74 ErasePath(&manager, "another_app_id", FPL("/ancestor/parent/self")); 86 ErasePath(&manager, "another_app_id", FPL("/ancestor/parent/self"));
75 87
76 EXPECT_TRUE(InsertPath(&manager, "app_id", FPL("/file"))); 88 EXPECT_TRUE(InsertPath(&manager, "app_id", FPL("/file")));
77 ErasePath(&manager, "app_id", FPL("/file")); 89 ErasePath(&manager, "app_id", FPL("/file"));
78 90
79 ErasePath(&manager, "app_id", FPL("/ancestor/parent/self/child/descendant")); 91 ErasePath(&manager, "app_id", FPL("/ancestor/parent/self/child/descendant"));
80 } 92 }
81 93
94 TEST(TaskDependencyManagerTest, ExclusiveTask) {
95 TaskDependencyManager manager;
96
97 EXPECT_TRUE(InsertPath(&manager, "app_id", FPL("/foo/bar")));
98 EXPECT_FALSE(InsertExclusiveTask(&manager));
99 ErasePath(&manager, "app_id", FPL("/foo/bar"));
100
101 EXPECT_TRUE(InsertExclusiveTask(&manager));
102 EXPECT_FALSE(InsertPath(&manager, "app_id", FPL("/foo/bar")));
103 EraseExclusiveTask(&manager);
104
105 EXPECT_TRUE(InsertPath(&manager, "app_id", FPL("/foo/bar")));
106 ErasePath(&manager, "app_id", FPL("/foo/bar"));
107 }
108
82 } // namespace drive_backend 109 } // namespace drive_backend
83 } // namespace sync_file_system 110 } // namespace sync_file_system
OLDNEW
« no previous file with comments | « chrome/browser/sync_file_system/drive_backend/task_dependency_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698