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

Side by Side Diff: chrome/installer/util/conditional_work_item_list_unittest.cc

Issue 1976443005: Revert of Add best-effort/allow rollback flags on WorkItem. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@simple_list_tests
Patch Set: Created 4 years, 7 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/installer/util/conditional_work_item_list.h" 5 #include "chrome/installer/util/conditional_work_item_list.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/files/scoped_temp_dir.h" 10 #include "base/files/scoped_temp_dir.h"
(...skipping 15 matching lines...) Expand all
26 26
27 // Create the mock work items. 27 // Create the mock work items.
28 std::unique_ptr<StrictMockWorkItem> item1(new StrictMockWorkItem); 28 std::unique_ptr<StrictMockWorkItem> item1(new StrictMockWorkItem);
29 std::unique_ptr<StrictMockWorkItem> item2(new StrictMockWorkItem); 29 std::unique_ptr<StrictMockWorkItem> item2(new StrictMockWorkItem);
30 std::unique_ptr<StrictMockWorkItem> item3(new StrictMockWorkItem); 30 std::unique_ptr<StrictMockWorkItem> item3(new StrictMockWorkItem);
31 31
32 { 32 {
33 // Expect all three items to be done in order then undone. 33 // Expect all three items to be done in order then undone.
34 InSequence s; 34 InSequence s;
35 35
36 EXPECT_CALL(*item1, DoImpl()).WillOnce(Return(true)); 36 EXPECT_CALL(*item1, Do()).WillOnce(Return(true));
37 EXPECT_CALL(*item2, DoImpl()).WillOnce(Return(true)); 37 EXPECT_CALL(*item2, Do()).WillOnce(Return(true));
38 EXPECT_CALL(*item3, DoImpl()).WillOnce(Return(true)); 38 EXPECT_CALL(*item3, Do()).WillOnce(Return(true));
39 EXPECT_CALL(*item3, RollbackImpl()); 39 EXPECT_CALL(*item3, Rollback());
40 EXPECT_CALL(*item2, RollbackImpl()); 40 EXPECT_CALL(*item2, Rollback());
41 EXPECT_CALL(*item1, RollbackImpl()); 41 EXPECT_CALL(*item1, Rollback());
42 } 42 }
43 43
44 // Add the items to the list. 44 // Add the items to the list.
45 list->AddWorkItem(item1.release()); 45 list->AddWorkItem(item1.release());
46 list->AddWorkItem(item2.release()); 46 list->AddWorkItem(item2.release());
47 list->AddWorkItem(item3.release()); 47 list->AddWorkItem(item3.release());
48 48
49 // Do and rollback the list. 49 // Do and rollback the list.
50 EXPECT_TRUE(list->Do()); 50 EXPECT_TRUE(list->Do());
51 list->Rollback(); 51 list->Rollback();
52 } 52 }
53 53
54 // Execute a ConditionalWorkItemList whose condition is met. Fail in the middle. 54 // Execute a ConditionalWorkItemList whose condition is met. Fail in the middle.
55 // Rollback what has been done. 55 // Rollback what has been done.
56 TEST(ConditionalWorkItemListTest, ExecutionFailAndRollback) { 56 TEST(ConditionalWorkItemListTest, ExecutionFailAndRollback) {
57 std::unique_ptr<StrictMockCondition> condition(new StrictMockCondition); 57 std::unique_ptr<StrictMockCondition> condition(new StrictMockCondition);
58 EXPECT_CALL(*condition, ShouldRun()).WillOnce(Return(true)); 58 EXPECT_CALL(*condition, ShouldRun()).WillOnce(Return(true));
59 std::unique_ptr<WorkItemList> list( 59 std::unique_ptr<WorkItemList> list(
60 WorkItem::CreateConditionalWorkItemList(condition.release())); 60 WorkItem::CreateConditionalWorkItemList(condition.release()));
61 61
62 // Create the mock work items. 62 // Create the mock work items.
63 std::unique_ptr<StrictMockWorkItem> item1(new StrictMockWorkItem); 63 std::unique_ptr<StrictMockWorkItem> item1(new StrictMockWorkItem);
64 std::unique_ptr<StrictMockWorkItem> item2(new StrictMockWorkItem); 64 std::unique_ptr<StrictMockWorkItem> item2(new StrictMockWorkItem);
65 std::unique_ptr<StrictMockWorkItem> item3(new StrictMockWorkItem); 65 std::unique_ptr<StrictMockWorkItem> item3(new StrictMockWorkItem);
66 66
67 { 67 {
68 // Expect the two first work items to be done in order then undone. 68 // Expect the two first work items to be done in order then undone.
69 InSequence s; 69 InSequence s;
70 70
71 EXPECT_CALL(*item1, DoImpl()).WillOnce(Return(true)); 71 EXPECT_CALL(*item1, Do()).WillOnce(Return(true));
72 EXPECT_CALL(*item2, DoImpl()).WillOnce(Return(false)); 72 EXPECT_CALL(*item2, Do()).WillOnce(Return(false));
73 EXPECT_CALL(*item2, RollbackImpl()); 73 EXPECT_CALL(*item2, Rollback());
74 EXPECT_CALL(*item1, RollbackImpl()); 74 EXPECT_CALL(*item1, Rollback());
75 } 75 }
76 76
77 // Add the items to the list. 77 // Add the items to the list.
78 list->AddWorkItem(item1.release()); 78 list->AddWorkItem(item1.release());
79 list->AddWorkItem(item2.release()); 79 list->AddWorkItem(item2.release());
80 list->AddWorkItem(item3.release()); 80 list->AddWorkItem(item3.release());
81 81
82 // Do and rollback the list. 82 // Do and rollback the list.
83 EXPECT_FALSE(list->Do()); 83 EXPECT_FALSE(list->Do());
84 list->Rollback(); 84 list->Rollback();
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 120
121 TEST(ConditionalWorkItemListTest, ConditionRunIfFileExists) { 121 TEST(ConditionalWorkItemListTest, ConditionRunIfFileExists) {
122 base::ScopedTempDir temp_dir; 122 base::ScopedTempDir temp_dir;
123 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); 123 ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
124 124
125 EXPECT_TRUE(ConditionRunIfFileExists(temp_dir.path()).ShouldRun()); 125 EXPECT_TRUE(ConditionRunIfFileExists(temp_dir.path()).ShouldRun());
126 EXPECT_FALSE(ConditionRunIfFileExists( 126 EXPECT_FALSE(ConditionRunIfFileExists(
127 temp_dir.path().Append(FILE_PATH_LITERAL("DoesNotExist"))) 127 temp_dir.path().Append(FILE_PATH_LITERAL("DoesNotExist")))
128 .ShouldRun()); 128 .ShouldRun());
129 } 129 }
OLDNEW
« no previous file with comments | « chrome/installer/util/conditional_work_item_list.cc ('k') | chrome/installer/util/copy_tree_work_item.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698