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

Side by Side Diff: action_unittest.cc

Issue 3022008: For actions, switch bool success into an exit code. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/update_engine.git
Patch Set: switch to all positive error codes. Created 10 years, 5 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 | « action_processor_unittest.cc ('k') | download_action.cc » ('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) 2009 The Chromium OS Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium OS 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 <string> 5 #include <string>
6 #include <gtest/gtest.h> 6 #include <gtest/gtest.h>
7 #include "update_engine/action.h" 7 #include "update_engine/action.h"
8 #include "update_engine/action_processor.h" 8 #include "update_engine/action_processor.h"
9 9
10 using std::string; 10 using std::string;
11 11
(...skipping 13 matching lines...) Expand all
25 // This is a simple Action class for testing. 25 // This is a simple Action class for testing.
26 struct ActionTestAction : public Action<ActionTestAction> { 26 struct ActionTestAction : public Action<ActionTestAction> {
27 typedef string InputObjectType; 27 typedef string InputObjectType;
28 typedef string OutputObjectType; 28 typedef string OutputObjectType;
29 ActionPipe<string>* in_pipe() { return in_pipe_.get(); } 29 ActionPipe<string>* in_pipe() { return in_pipe_.get(); }
30 ActionPipe<string>* out_pipe() { return out_pipe_.get(); } 30 ActionPipe<string>* out_pipe() { return out_pipe_.get(); }
31 ActionProcessor* processor() { return processor_; } 31 ActionProcessor* processor() { return processor_; }
32 void PerformAction() {} 32 void PerformAction() {}
33 void CompleteAction() { 33 void CompleteAction() {
34 ASSERT_TRUE(processor()); 34 ASSERT_TRUE(processor());
35 processor()->ActionComplete(this, true); 35 processor()->ActionComplete(this, kActionCodeSuccess);
36 } 36 }
37 string Type() const { return "ActionTestAction"; } 37 string Type() const { return "ActionTestAction"; }
38 }; 38 };
39 39
40 class ActionTest : public ::testing::Test { }; 40 class ActionTest : public ::testing::Test { };
41 41
42 // This test creates two simple Actions and sends a message via an ActionPipe 42 // This test creates two simple Actions and sends a message via an ActionPipe
43 // from one to the other. 43 // from one to the other.
44 TEST(ActionTest, SimpleTest) { 44 TEST(ActionTest, SimpleTest) {
45 ActionTestAction action; 45 ActionTestAction action;
46 46
47 EXPECT_FALSE(action.in_pipe()); 47 EXPECT_FALSE(action.in_pipe());
48 EXPECT_FALSE(action.out_pipe()); 48 EXPECT_FALSE(action.out_pipe());
49 EXPECT_FALSE(action.processor()); 49 EXPECT_FALSE(action.processor());
50 EXPECT_FALSE(action.IsRunning()); 50 EXPECT_FALSE(action.IsRunning());
51 51
52 ActionProcessor action_processor; 52 ActionProcessor action_processor;
53 action_processor.EnqueueAction(&action); 53 action_processor.EnqueueAction(&action);
54 EXPECT_EQ(&action_processor, action.processor()); 54 EXPECT_EQ(&action_processor, action.processor());
55 55
56 action_processor.StartProcessing(); 56 action_processor.StartProcessing();
57 EXPECT_TRUE(action.IsRunning()); 57 EXPECT_TRUE(action.IsRunning());
58 action.CompleteAction(); 58 action.CompleteAction();
59 EXPECT_FALSE(action.IsRunning()); 59 EXPECT_FALSE(action.IsRunning());
60 } 60 }
61 61
62 } // namespace chromeos_update_engine 62 } // namespace chromeos_update_engine
OLDNEW
« no previous file with comments | « action_processor_unittest.cc ('k') | download_action.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698