OLD | NEW |
1 // Copyright (c) 2009 The Chromium 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 |
6 #include <gtest/gtest.h> | 7 #include <gtest/gtest.h> |
| 8 |
7 #include "update_engine/omaha_response_handler_action.h" | 9 #include "update_engine/omaha_response_handler_action.h" |
| 10 #include "update_engine/prefs_mock.h" |
8 #include "update_engine/test_utils.h" | 11 #include "update_engine/test_utils.h" |
9 #include "update_engine/utils.h" | 12 #include "update_engine/utils.h" |
10 | 13 |
11 using std::string; | 14 using std::string; |
| 15 using testing::Return; |
12 | 16 |
13 namespace chromeos_update_engine { | 17 namespace chromeos_update_engine { |
14 | 18 |
15 class OmahaResponseHandlerActionTest : public ::testing::Test { | 19 class OmahaResponseHandlerActionTest : public ::testing::Test { |
16 public: | 20 public: |
17 // Return true iff the OmahaResponseHandlerAction succeeded. | 21 // Return true iff the OmahaResponseHandlerAction succeeded. |
18 // If out is non-NULL, it's set w/ the response from the action. | 22 // If out is non-NULL, it's set w/ the response from the action. |
19 bool DoTest(const OmahaResponse& in, | 23 bool DoTest(const OmahaResponse& in, |
20 const string& boot_dev, | 24 const string& boot_dev, |
21 InstallPlan* out); | 25 InstallPlan* out); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 | 57 |
54 bool OmahaResponseHandlerActionTest::DoTest(const OmahaResponse& in, | 58 bool OmahaResponseHandlerActionTest::DoTest(const OmahaResponse& in, |
55 const string& boot_dev, | 59 const string& boot_dev, |
56 InstallPlan* out) { | 60 InstallPlan* out) { |
57 ActionProcessor processor; | 61 ActionProcessor processor; |
58 OmahaResponseHandlerActionProcessorDelegate delegate; | 62 OmahaResponseHandlerActionProcessorDelegate delegate; |
59 processor.set_delegate(&delegate); | 63 processor.set_delegate(&delegate); |
60 | 64 |
61 ObjectFeederAction<OmahaResponse> feeder_action; | 65 ObjectFeederAction<OmahaResponse> feeder_action; |
62 feeder_action.set_obj(in); | 66 feeder_action.set_obj(in); |
63 OmahaResponseHandlerAction response_handler_action; | 67 PrefsMock prefs; |
| 68 if (in.update_exists) { |
| 69 EXPECT_CALL(prefs, SetString(kPrefsUpdateCheckResponseHash, in.hash)) |
| 70 .WillOnce(Return(true)); |
| 71 } |
| 72 OmahaResponseHandlerAction response_handler_action(&prefs); |
64 response_handler_action.set_boot_device(boot_dev); | 73 response_handler_action.set_boot_device(boot_dev); |
65 BondActions(&feeder_action, &response_handler_action); | 74 BondActions(&feeder_action, &response_handler_action); |
66 ObjectCollectorAction<InstallPlan> collector_action; | 75 ObjectCollectorAction<InstallPlan> collector_action; |
67 BondActions(&response_handler_action, &collector_action); | 76 BondActions(&response_handler_action, &collector_action); |
68 processor.EnqueueAction(&feeder_action); | 77 processor.EnqueueAction(&feeder_action); |
69 processor.EnqueueAction(&response_handler_action); | 78 processor.EnqueueAction(&response_handler_action); |
70 processor.EnqueueAction(&collector_action); | 79 processor.EnqueueAction(&collector_action); |
71 processor.StartProcessing(); | 80 processor.StartProcessing(); |
72 EXPECT_TRUE(!processor.IsRunning()) | 81 EXPECT_TRUE(!processor.IsRunning()) |
73 << "Update test to handle non-asynch actions"; | 82 << "Update test to handle non-asynch actions"; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 in.update_exists = false; | 148 in.update_exists = false; |
140 InstallPlan install_plan; | 149 InstallPlan install_plan; |
141 EXPECT_FALSE(DoTest(in, "/dev/sda1", &install_plan)); | 150 EXPECT_FALSE(DoTest(in, "/dev/sda1", &install_plan)); |
142 EXPECT_FALSE(install_plan.is_full_update); | 151 EXPECT_FALSE(install_plan.is_full_update); |
143 EXPECT_EQ("", install_plan.download_url); | 152 EXPECT_EQ("", install_plan.download_url); |
144 EXPECT_EQ("", install_plan.download_hash); | 153 EXPECT_EQ("", install_plan.download_hash); |
145 EXPECT_EQ("", install_plan.install_path); | 154 EXPECT_EQ("", install_plan.install_path); |
146 } | 155 } |
147 | 156 |
148 } // namespace chromeos_update_engine | 157 } // namespace chromeos_update_engine |
OLD | NEW |