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

Side by Side Diff: chrome/installer/util/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
« no previous file with comments | « chrome/installer/util/work_item_list.cc ('k') | chrome/installer/util/work_item_mocks.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/work_item_list.h" 5 #include "chrome/installer/util/work_item_list.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "chrome/installer/util/work_item.h" 10 #include "chrome/installer/util/work_item.h"
(...skipping 10 matching lines...) Expand all
21 21
22 // Create the mock work items. 22 // Create the mock work items.
23 std::unique_ptr<StrictMockWorkItem> item1(new StrictMockWorkItem); 23 std::unique_ptr<StrictMockWorkItem> item1(new StrictMockWorkItem);
24 std::unique_ptr<StrictMockWorkItem> item2(new StrictMockWorkItem); 24 std::unique_ptr<StrictMockWorkItem> item2(new StrictMockWorkItem);
25 std::unique_ptr<StrictMockWorkItem> item3(new StrictMockWorkItem); 25 std::unique_ptr<StrictMockWorkItem> item3(new StrictMockWorkItem);
26 26
27 { 27 {
28 // Expect all three items to be done in order then undone. 28 // Expect all three items to be done in order then undone.
29 InSequence s; 29 InSequence s;
30 30
31 EXPECT_CALL(*item1, DoImpl()).WillOnce(Return(true)); 31 EXPECT_CALL(*item1, Do()).WillOnce(Return(true));
32 EXPECT_CALL(*item2, DoImpl()).WillOnce(Return(true)); 32 EXPECT_CALL(*item2, Do()).WillOnce(Return(true));
33 EXPECT_CALL(*item3, DoImpl()).WillOnce(Return(true)); 33 EXPECT_CALL(*item3, Do()).WillOnce(Return(true));
34 EXPECT_CALL(*item3, RollbackImpl()); 34 EXPECT_CALL(*item3, Rollback());
35 EXPECT_CALL(*item2, RollbackImpl()); 35 EXPECT_CALL(*item2, Rollback());
36 EXPECT_CALL(*item1, RollbackImpl()); 36 EXPECT_CALL(*item1, Rollback());
37 } 37 }
38 38
39 // Add the items to the list. 39 // Add the items to the list.
40 list->AddWorkItem(item1.release()); 40 list->AddWorkItem(item1.release());
41 list->AddWorkItem(item2.release()); 41 list->AddWorkItem(item2.release());
42 list->AddWorkItem(item3.release()); 42 list->AddWorkItem(item3.release());
43 43
44 // Do and rollback the list. 44 // Do and rollback the list.
45 EXPECT_TRUE(list->Do()); 45 EXPECT_TRUE(list->Do());
46 list->Rollback(); 46 list->Rollback();
47 } 47 }
48 48
49 // Execute a WorkItemList. Fail in the middle. Rollback what has been done. 49 // Execute a WorkItemList. Fail in the middle. Rollback what has been done.
50 TEST(WorkItemListTest, ExecutionFailAndRollback) { 50 TEST(WorkItemListTest, ExecutionFailAndRollback) {
51 std::unique_ptr<WorkItemList> list(WorkItem::CreateWorkItemList()); 51 std::unique_ptr<WorkItemList> list(WorkItem::CreateWorkItemList());
52 52
53 // Create the mock work items. 53 // Create the mock work items.
54 std::unique_ptr<StrictMockWorkItem> item1(new StrictMockWorkItem); 54 std::unique_ptr<StrictMockWorkItem> item1(new StrictMockWorkItem);
55 std::unique_ptr<StrictMockWorkItem> item2(new StrictMockWorkItem); 55 std::unique_ptr<StrictMockWorkItem> item2(new StrictMockWorkItem);
56 std::unique_ptr<StrictMockWorkItem> item3(new StrictMockWorkItem); 56 std::unique_ptr<StrictMockWorkItem> item3(new StrictMockWorkItem);
57 57
58 { 58 {
59 // Expect the two first work items to be done in order then undone. 59 // Expect the two first work items to be done in order then undone.
60 InSequence s; 60 InSequence s;
61 61
62 EXPECT_CALL(*item1, DoImpl()).WillOnce(Return(true)); 62 EXPECT_CALL(*item1, Do()).WillOnce(Return(true));
63 EXPECT_CALL(*item2, DoImpl()).WillOnce(Return(false)); 63 EXPECT_CALL(*item2, Do()).WillOnce(Return(false));
64 EXPECT_CALL(*item2, RollbackImpl()); 64 EXPECT_CALL(*item2, Rollback());
65 EXPECT_CALL(*item1, RollbackImpl()); 65 EXPECT_CALL(*item1, Rollback());
66 } 66 }
67 67
68 // Add the items to the list. 68 // Add the items to the list.
69 list->AddWorkItem(item1.release()); 69 list->AddWorkItem(item1.release());
70 list->AddWorkItem(item2.release()); 70 list->AddWorkItem(item2.release());
71 list->AddWorkItem(item3.release()); 71 list->AddWorkItem(item3.release());
72 72
73 // Do and rollback the list. 73 // Do and rollback the list.
74 EXPECT_FALSE(list->Do()); 74 EXPECT_FALSE(list->Do());
75 list->Rollback(); 75 list->Rollback();
76 } 76 }
OLDNEW
« no previous file with comments | « chrome/installer/util/work_item_list.cc ('k') | chrome/installer/util/work_item_mocks.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698