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

Side by Side Diff: omaha_response_handler_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 | « omaha_response_handler_action.cc ('k') | postinstall_runner_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 Authors. All rights reserved. 1 // Copyright (c) 2009 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 <string> 5 #include <string>
6 #include <gtest/gtest.h> 6 #include <gtest/gtest.h>
7 #include "update_engine/omaha_response_handler_action.h" 7 #include "update_engine/omaha_response_handler_action.h"
8 #include "update_engine/test_utils.h" 8 #include "update_engine/test_utils.h"
9 #include "update_engine/utils.h" 9 #include "update_engine/utils.h"
10 10
11 using std::string; 11 using std::string;
12 12
13 namespace chromeos_update_engine { 13 namespace chromeos_update_engine {
14 14
15 class OmahaResponseHandlerActionTest : public ::testing::Test { 15 class OmahaResponseHandlerActionTest : public ::testing::Test {
16 public: 16 public:
17 // Return true iff the OmahaResponseHandlerAction succeeded. 17 // Return true iff the OmahaResponseHandlerAction succeeded.
18 // If out is non-NULL, it's set w/ the response from the action. 18 // If out is non-NULL, it's set w/ the response from the action.
19 bool DoTest(const OmahaResponse& in, 19 bool DoTest(const OmahaResponse& in,
20 const string& boot_dev, 20 const string& boot_dev,
21 InstallPlan* out); 21 InstallPlan* out);
22 }; 22 };
23 23
24 class OmahaResponseHandlerActionProcessorDelegate 24 class OmahaResponseHandlerActionProcessorDelegate
25 : public ActionProcessorDelegate { 25 : public ActionProcessorDelegate {
26 public: 26 public:
27 OmahaResponseHandlerActionProcessorDelegate() 27 OmahaResponseHandlerActionProcessorDelegate()
28 : success_(false), 28 : code_(kActionCodeError),
29 success_set_(false) {} 29 code_set_(false) {}
30 void ActionCompleted(ActionProcessor* processor, 30 void ActionCompleted(ActionProcessor* processor,
31 AbstractAction* action, 31 AbstractAction* action,
32 bool success) { 32 ActionExitCode code) {
33 if (action->Type() == OmahaResponseHandlerAction::StaticType()) { 33 if (action->Type() == OmahaResponseHandlerAction::StaticType()) {
34 success_ = success; 34 code_ = code;
35 success_set_ = true; 35 code_set_ = true;
36 } 36 }
37 } 37 }
38 bool success_; 38 ActionExitCode code_;
39 bool success_set_; 39 bool code_set_;
40 }; 40 };
41 41
42 namespace { 42 namespace {
43 const string kLongName = 43 const string kLongName =
44 "very_long_name_and_no_slashes-very_long_name_and_no_slashes" 44 "very_long_name_and_no_slashes-very_long_name_and_no_slashes"
45 "very_long_name_and_no_slashes-very_long_name_and_no_slashes" 45 "very_long_name_and_no_slashes-very_long_name_and_no_slashes"
46 "very_long_name_and_no_slashes-very_long_name_and_no_slashes" 46 "very_long_name_and_no_slashes-very_long_name_and_no_slashes"
47 "very_long_name_and_no_slashes-very_long_name_and_no_slashes" 47 "very_long_name_and_no_slashes-very_long_name_and_no_slashes"
48 "very_long_name_and_no_slashes-very_long_name_and_no_slashes" 48 "very_long_name_and_no_slashes-very_long_name_and_no_slashes"
49 "very_long_name_and_no_slashes-very_long_name_and_no_slashes" 49 "very_long_name_and_no_slashes-very_long_name_and_no_slashes"
(...skipping 16 matching lines...) Expand all
66 ObjectCollectorAction<InstallPlan> collector_action; 66 ObjectCollectorAction<InstallPlan> collector_action;
67 BondActions(&response_handler_action, &collector_action); 67 BondActions(&response_handler_action, &collector_action);
68 processor.EnqueueAction(&feeder_action); 68 processor.EnqueueAction(&feeder_action);
69 processor.EnqueueAction(&response_handler_action); 69 processor.EnqueueAction(&response_handler_action);
70 processor.EnqueueAction(&collector_action); 70 processor.EnqueueAction(&collector_action);
71 processor.StartProcessing(); 71 processor.StartProcessing();
72 EXPECT_TRUE(!processor.IsRunning()) 72 EXPECT_TRUE(!processor.IsRunning())
73 << "Update test to handle non-asynch actions"; 73 << "Update test to handle non-asynch actions";
74 if (out) 74 if (out)
75 *out = collector_action.object(); 75 *out = collector_action.object();
76 EXPECT_TRUE(delegate.success_set_); 76 EXPECT_TRUE(delegate.code_set_);
77 return delegate.success_; 77 return delegate.code_ == kActionCodeSuccess;
78 } 78 }
79 79
80 TEST_F(OmahaResponseHandlerActionTest, SimpleTest) { 80 TEST_F(OmahaResponseHandlerActionTest, SimpleTest) {
81 { 81 {
82 OmahaResponse in; 82 OmahaResponse in;
83 in.update_exists = true; 83 in.update_exists = true;
84 in.display_version = "a.b.c.d"; 84 in.display_version = "a.b.c.d";
85 in.codebase = "http://foo/the_update_a.b.c.d.tgz"; 85 in.codebase = "http://foo/the_update_a.b.c.d.tgz";
86 in.more_info_url = "http://more/info"; 86 in.more_info_url = "http://more/info";
87 in.hash = "HASH+"; 87 in.hash = "HASH+";
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 in.update_exists = false; 139 in.update_exists = false;
140 InstallPlan install_plan; 140 InstallPlan install_plan;
141 EXPECT_FALSE(DoTest(in, "/dev/sda1", &install_plan)); 141 EXPECT_FALSE(DoTest(in, "/dev/sda1", &install_plan));
142 EXPECT_FALSE(install_plan.is_full_update); 142 EXPECT_FALSE(install_plan.is_full_update);
143 EXPECT_EQ("", install_plan.download_url); 143 EXPECT_EQ("", install_plan.download_url);
144 EXPECT_EQ("", install_plan.download_hash); 144 EXPECT_EQ("", install_plan.download_hash);
145 EXPECT_EQ("", install_plan.install_path); 145 EXPECT_EQ("", install_plan.install_path);
146 } 146 }
147 147
148 } // namespace chromeos_update_engine 148 } // namespace chromeos_update_engine
OLDNEW
« no previous file with comments | « omaha_response_handler_action.cc ('k') | postinstall_runner_action.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698