| OLD | NEW |
| 1 // Copyright (c) 2010 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 <base/file_util.h> | 5 #include <base/file_util.h> |
| 6 #include <gtest/gtest.h> | 6 #include <gtest/gtest.h> |
| 7 | 7 |
| 8 #include "update_engine/action_mock.h" | 8 #include "update_engine/action_mock.h" |
| 9 #include "update_engine/action_processor_mock.h" | 9 #include "update_engine/action_processor_mock.h" |
| 10 #include "update_engine/filesystem_copier_action.h" | 10 #include "update_engine/filesystem_copier_action.h" |
| 11 #include "update_engine/postinstall_runner_action.h" | 11 #include "update_engine/postinstall_runner_action.h" |
| 12 #include "update_engine/prefs_mock.h" | 12 #include "update_engine/prefs_mock.h" |
| 13 #include "update_engine/set_bootable_flag_action.h" | |
| 14 #include "update_engine/update_attempter.h" | 13 #include "update_engine/update_attempter.h" |
| 15 | 14 |
| 16 using std::string; | 15 using std::string; |
| 17 using testing::_; | 16 using testing::_; |
| 18 using testing::DoAll; | 17 using testing::DoAll; |
| 19 using testing::InSequence; | 18 using testing::InSequence; |
| 20 using testing::Ne; | 19 using testing::Ne; |
| 21 using testing::Property; | 20 using testing::Property; |
| 22 using testing::Return; | 21 using testing::Return; |
| 23 using testing::SetArgumentPointee; | 22 using testing::SetArgumentPointee; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 EXPECT_EQ(kActionCodeOmahaResponseHandlerError, | 82 EXPECT_EQ(kActionCodeOmahaResponseHandlerError, |
| 84 GetErrorCodeForAction(&omaha_response_handler_action, | 83 GetErrorCodeForAction(&omaha_response_handler_action, |
| 85 kActionCodeError)); | 84 kActionCodeError)); |
| 86 FilesystemCopierAction filesystem_copier_action(false); | 85 FilesystemCopierAction filesystem_copier_action(false); |
| 87 EXPECT_EQ(kActionCodeFilesystemCopierError, | 86 EXPECT_EQ(kActionCodeFilesystemCopierError, |
| 88 GetErrorCodeForAction(&filesystem_copier_action, kActionCodeError)); | 87 GetErrorCodeForAction(&filesystem_copier_action, kActionCodeError)); |
| 89 PostinstallRunnerAction postinstall_runner_action(true); | 88 PostinstallRunnerAction postinstall_runner_action(true); |
| 90 EXPECT_EQ(kActionCodePostinstallRunnerError, | 89 EXPECT_EQ(kActionCodePostinstallRunnerError, |
| 91 GetErrorCodeForAction(&postinstall_runner_action, | 90 GetErrorCodeForAction(&postinstall_runner_action, |
| 92 kActionCodeError)); | 91 kActionCodeError)); |
| 93 SetBootableFlagAction set_bootable_flag_action; | |
| 94 EXPECT_EQ(kActionCodeSetBootableFlagError, | |
| 95 GetErrorCodeForAction(&set_bootable_flag_action, | |
| 96 kActionCodeError)); | |
| 97 ActionMock action_mock; | 92 ActionMock action_mock; |
| 98 EXPECT_CALL(action_mock, Type()).Times(1).WillOnce(Return("ActionMock")); | 93 EXPECT_CALL(action_mock, Type()).Times(1).WillOnce(Return("ActionMock")); |
| 99 EXPECT_EQ(kActionCodeError, | 94 EXPECT_EQ(kActionCodeError, |
| 100 GetErrorCodeForAction(&action_mock, kActionCodeError)); | 95 GetErrorCodeForAction(&action_mock, kActionCodeError)); |
| 101 } | 96 } |
| 102 | 97 |
| 103 TEST_F(UpdateAttempterTest, DisableDeltaUpdateIfNeededTest) { | 98 TEST_F(UpdateAttempterTest, DisableDeltaUpdateIfNeededTest) { |
| 104 attempter_.omaha_request_params_.delta_okay = true; | 99 attempter_.omaha_request_params_.delta_okay = true; |
| 105 EXPECT_CALL(prefs_, GetInt64(kPrefsDeltaUpdateFailures, _)) | 100 EXPECT_CALL(prefs_, GetInt64(kPrefsDeltaUpdateFailures, _)) |
| 106 .WillOnce(Return(false)); | 101 .WillOnce(Return(false)); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 InSequence s; | 164 InSequence s; |
| 170 const string kActionTypes[] = { | 165 const string kActionTypes[] = { |
| 171 OmahaRequestAction::StaticType(), | 166 OmahaRequestAction::StaticType(), |
| 172 OmahaResponseHandlerAction::StaticType(), | 167 OmahaResponseHandlerAction::StaticType(), |
| 173 FilesystemCopierAction::StaticType(), | 168 FilesystemCopierAction::StaticType(), |
| 174 FilesystemCopierAction::StaticType(), | 169 FilesystemCopierAction::StaticType(), |
| 175 OmahaRequestAction::StaticType(), | 170 OmahaRequestAction::StaticType(), |
| 176 DownloadAction::StaticType(), | 171 DownloadAction::StaticType(), |
| 177 OmahaRequestAction::StaticType(), | 172 OmahaRequestAction::StaticType(), |
| 178 PostinstallRunnerAction::StaticType(), | 173 PostinstallRunnerAction::StaticType(), |
| 179 SetBootableFlagAction::StaticType(), | |
| 180 PostinstallRunnerAction::StaticType(), | 174 PostinstallRunnerAction::StaticType(), |
| 181 OmahaRequestAction::StaticType() | 175 OmahaRequestAction::StaticType() |
| 182 }; | 176 }; |
| 183 for (size_t i = 0; i < arraysize(kActionTypes); ++i) { | 177 for (size_t i = 0; i < arraysize(kActionTypes); ++i) { |
| 184 EXPECT_CALL(*processor_, | 178 EXPECT_CALL(*processor_, |
| 185 EnqueueAction(Property(&AbstractAction::Type, | 179 EnqueueAction(Property(&AbstractAction::Type, |
| 186 kActionTypes[i]))).Times(1); | 180 kActionTypes[i]))).Times(1); |
| 187 } | 181 } |
| 188 EXPECT_CALL(*processor_, StartProcessing()).Times(1); | 182 EXPECT_CALL(*processor_, StartProcessing()).Times(1); |
| 189 | 183 |
| 190 attempter_.Update("", ""); | 184 attempter_.Update("", ""); |
| 191 | 185 |
| 192 EXPECT_EQ(0, attempter_.http_response_code()); | 186 EXPECT_EQ(0, attempter_.http_response_code()); |
| 193 EXPECT_EQ(&attempter_, processor_->delegate()); | 187 EXPECT_EQ(&attempter_, processor_->delegate()); |
| 194 EXPECT_EQ(arraysize(kActionTypes), attempter_.actions_.size()); | 188 EXPECT_EQ(arraysize(kActionTypes), attempter_.actions_.size()); |
| 195 for (size_t i = 0; i < arraysize(kActionTypes); ++i) { | 189 for (size_t i = 0; i < arraysize(kActionTypes); ++i) { |
| 196 EXPECT_EQ(kActionTypes[i], attempter_.actions_[i]->Type()); | 190 EXPECT_EQ(kActionTypes[i], attempter_.actions_[i]->Type()); |
| 197 } | 191 } |
| 198 EXPECT_EQ(attempter_.response_handler_action_.get(), | 192 EXPECT_EQ(attempter_.response_handler_action_.get(), |
| 199 attempter_.actions_[1].get()); | 193 attempter_.actions_[1].get()); |
| 200 DownloadAction* download_action = | 194 DownloadAction* download_action = |
| 201 dynamic_cast<DownloadAction*>(attempter_.actions_[5].get()); | 195 dynamic_cast<DownloadAction*>(attempter_.actions_[5].get()); |
| 202 ASSERT_TRUE(download_action != NULL); | 196 ASSERT_TRUE(download_action != NULL); |
| 203 EXPECT_EQ(&attempter_, download_action->delegate()); | 197 EXPECT_EQ(&attempter_, download_action->delegate()); |
| 204 EXPECT_EQ(UPDATE_STATUS_CHECKING_FOR_UPDATE, attempter_.status()); | 198 EXPECT_EQ(UPDATE_STATUS_CHECKING_FOR_UPDATE, attempter_.status()); |
| 205 } | 199 } |
| 206 | 200 |
| 207 } // namespace chromeos_update_engine | 201 } // namespace chromeos_update_engine |
| OLD | NEW |