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

Side by Side Diff: omaha_response_handler_action_unittest.cc

Issue 2981007: Rename UpdateCheckAction|Params to OmahaRequestAction|Params. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/update_engine.git
Patch Set: fix the comment 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') | update_attempter.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 UpdateCheckResponse& 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 : success_(false),
29 success_set_(false) {} 29 success_set_(false) {}
(...skipping 14 matching lines...) Expand all
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"
50 "very_long_name_and_no_slashes-very_long_name_and_no_slashes" 50 "very_long_name_and_no_slashes-very_long_name_and_no_slashes"
51 "-the_update_a.b.c.d_DELTA_.tgz"; 51 "-the_update_a.b.c.d_DELTA_.tgz";
52 } // namespace {} 52 } // namespace {}
53 53
54 bool OmahaResponseHandlerActionTest::DoTest(const UpdateCheckResponse& in, 54 bool OmahaResponseHandlerActionTest::DoTest(const OmahaResponse& in,
55 const string& boot_dev, 55 const string& boot_dev,
56 InstallPlan* out) { 56 InstallPlan* out) {
57 ActionProcessor processor; 57 ActionProcessor processor;
58 OmahaResponseHandlerActionProcessorDelegate delegate; 58 OmahaResponseHandlerActionProcessorDelegate delegate;
59 processor.set_delegate(&delegate); 59 processor.set_delegate(&delegate);
60 60
61 ObjectFeederAction<UpdateCheckResponse> feeder_action; 61 ObjectFeederAction<OmahaResponse> feeder_action;
62 feeder_action.set_obj(in); 62 feeder_action.set_obj(in);
63 OmahaResponseHandlerAction response_handler_action; 63 OmahaResponseHandlerAction response_handler_action;
64 response_handler_action.set_boot_device(boot_dev); 64 response_handler_action.set_boot_device(boot_dev);
65 BondActions(&feeder_action, &response_handler_action); 65 BondActions(&feeder_action, &response_handler_action);
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.success_set_);
77 return delegate.success_; 77 return delegate.success_;
78 } 78 }
79 79
80 TEST_F(OmahaResponseHandlerActionTest, SimpleTest) { 80 TEST_F(OmahaResponseHandlerActionTest, SimpleTest) {
81 { 81 {
82 UpdateCheckResponse 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+";
88 in.size = 12; 88 in.size = 12;
89 in.needs_admin = true; 89 in.needs_admin = true;
90 in.prompt = false; 90 in.prompt = false;
91 InstallPlan install_plan; 91 InstallPlan install_plan;
92 EXPECT_TRUE(DoTest(in, "/dev/sda3", &install_plan)); 92 EXPECT_TRUE(DoTest(in, "/dev/sda3", &install_plan));
93 EXPECT_TRUE(install_plan.is_full_update); 93 EXPECT_TRUE(install_plan.is_full_update);
94 EXPECT_EQ(in.codebase, install_plan.download_url); 94 EXPECT_EQ(in.codebase, install_plan.download_url);
95 EXPECT_EQ(in.hash, install_plan.download_hash); 95 EXPECT_EQ(in.hash, install_plan.download_hash);
96 EXPECT_EQ("/dev/sda5", install_plan.install_path); 96 EXPECT_EQ("/dev/sda5", install_plan.install_path);
97 } 97 }
98 { 98 {
99 UpdateCheckResponse in; 99 OmahaResponse in;
100 in.update_exists = true; 100 in.update_exists = true;
101 in.display_version = "a.b.c.d"; 101 in.display_version = "a.b.c.d";
102 in.codebase = "http://foo/the_update_a.b.c.d.tgz"; 102 in.codebase = "http://foo/the_update_a.b.c.d.tgz";
103 in.more_info_url = "http://more/info"; 103 in.more_info_url = "http://more/info";
104 in.hash = "HASHj+"; 104 in.hash = "HASHj+";
105 in.size = 12; 105 in.size = 12;
106 in.needs_admin = true; 106 in.needs_admin = true;
107 in.prompt = true; 107 in.prompt = true;
108 InstallPlan install_plan; 108 InstallPlan install_plan;
109 EXPECT_TRUE(DoTest(in, "/dev/sda5", &install_plan)); 109 EXPECT_TRUE(DoTest(in, "/dev/sda5", &install_plan));
110 EXPECT_TRUE(install_plan.is_full_update); 110 EXPECT_TRUE(install_plan.is_full_update);
111 EXPECT_EQ(in.codebase, install_plan.download_url); 111 EXPECT_EQ(in.codebase, install_plan.download_url);
112 EXPECT_EQ(in.hash, install_plan.download_hash); 112 EXPECT_EQ(in.hash, install_plan.download_hash);
113 EXPECT_EQ("/dev/sda3", install_plan.install_path); 113 EXPECT_EQ("/dev/sda3", install_plan.install_path);
114 } 114 }
115 { 115 {
116 UpdateCheckResponse in; 116 OmahaResponse in;
117 in.update_exists = true; 117 in.update_exists = true;
118 in.display_version = "a.b.c.d"; 118 in.display_version = "a.b.c.d";
119 in.codebase = kLongName; 119 in.codebase = kLongName;
120 in.more_info_url = "http://more/info"; 120 in.more_info_url = "http://more/info";
121 in.hash = "HASHj+"; 121 in.hash = "HASHj+";
122 in.size = 12; 122 in.size = 12;
123 in.needs_admin = true; 123 in.needs_admin = true;
124 in.prompt = true; 124 in.prompt = true;
125 InstallPlan install_plan; 125 InstallPlan install_plan;
126 EXPECT_TRUE(DoTest(in, "/dev/sda3", &install_plan)); 126 EXPECT_TRUE(DoTest(in, "/dev/sda3", &install_plan));
127 EXPECT_TRUE(install_plan.is_full_update); 127 EXPECT_TRUE(install_plan.is_full_update);
128 EXPECT_EQ(in.codebase, install_plan.download_url); 128 EXPECT_EQ(in.codebase, install_plan.download_url);
129 EXPECT_EQ(in.hash, install_plan.download_hash); 129 EXPECT_EQ(in.hash, install_plan.download_hash);
130 EXPECT_EQ("/dev/sda5", install_plan.install_path); 130 EXPECT_EQ("/dev/sda5", install_plan.install_path);
131 } 131 }
132 } 132 }
133 133
134 TEST_F(OmahaResponseHandlerActionTest, NoUpdatesTest) { 134 TEST_F(OmahaResponseHandlerActionTest, NoUpdatesTest) {
135 UpdateCheckResponse in; 135 OmahaResponse in;
136 in.update_exists = false; 136 in.update_exists = false;
137 InstallPlan install_plan; 137 InstallPlan install_plan;
138 EXPECT_FALSE(DoTest(in, "/dev/sda1", &install_plan)); 138 EXPECT_FALSE(DoTest(in, "/dev/sda1", &install_plan));
139 EXPECT_FALSE(install_plan.is_full_update); 139 EXPECT_FALSE(install_plan.is_full_update);
140 EXPECT_EQ("", install_plan.download_url); 140 EXPECT_EQ("", install_plan.download_url);
141 EXPECT_EQ("", install_plan.download_hash); 141 EXPECT_EQ("", install_plan.download_hash);
142 EXPECT_EQ("", install_plan.install_path); 142 EXPECT_EQ("", install_plan.install_path);
143 } 143 }
144 144
145 } // namespace chromeos_update_engine 145 } // namespace chromeos_update_engine
OLDNEW
« no previous file with comments | « omaha_response_handler_action.cc ('k') | update_attempter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698