| 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" |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 GetErrorCodeForAction(NULL, kActionCodeSuccess)); | 122 GetErrorCodeForAction(NULL, kActionCodeSuccess)); |
| 123 | 123 |
| 124 OmahaRequestParams params; | 124 OmahaRequestParams params; |
| 125 OmahaRequestAction omaha_request_action(NULL, params, NULL, NULL); | 125 OmahaRequestAction omaha_request_action(NULL, params, NULL, NULL); |
| 126 EXPECT_EQ(kActionCodeOmahaRequestError, | 126 EXPECT_EQ(kActionCodeOmahaRequestError, |
| 127 GetErrorCodeForAction(&omaha_request_action, kActionCodeError)); | 127 GetErrorCodeForAction(&omaha_request_action, kActionCodeError)); |
| 128 OmahaResponseHandlerAction omaha_response_handler_action(&prefs_); | 128 OmahaResponseHandlerAction omaha_response_handler_action(&prefs_); |
| 129 EXPECT_EQ(kActionCodeOmahaResponseHandlerError, | 129 EXPECT_EQ(kActionCodeOmahaResponseHandlerError, |
| 130 GetErrorCodeForAction(&omaha_response_handler_action, | 130 GetErrorCodeForAction(&omaha_response_handler_action, |
| 131 kActionCodeError)); | 131 kActionCodeError)); |
| 132 FilesystemCopierAction filesystem_copier_action(false); | 132 FilesystemCopierAction filesystem_copier_action(false, false); |
| 133 EXPECT_EQ(kActionCodeFilesystemCopierError, | 133 EXPECT_EQ(kActionCodeFilesystemCopierError, |
| 134 GetErrorCodeForAction(&filesystem_copier_action, kActionCodeError)); | 134 GetErrorCodeForAction(&filesystem_copier_action, kActionCodeError)); |
| 135 PostinstallRunnerAction postinstall_runner_action; | 135 PostinstallRunnerAction postinstall_runner_action; |
| 136 EXPECT_EQ(kActionCodePostinstallRunnerError, | 136 EXPECT_EQ(kActionCodePostinstallRunnerError, |
| 137 GetErrorCodeForAction(&postinstall_runner_action, | 137 GetErrorCodeForAction(&postinstall_runner_action, |
| 138 kActionCodeError)); | 138 kActionCodeError)); |
| 139 ActionMock action_mock; | 139 ActionMock action_mock; |
| 140 EXPECT_CALL(action_mock, Type()).Times(1).WillOnce(Return("ActionMock")); | 140 EXPECT_CALL(action_mock, Type()).Times(1).WillOnce(Return("ActionMock")); |
| 141 EXPECT_EQ(kActionCodeError, | 141 EXPECT_EQ(kActionCodeError, |
| 142 GetErrorCodeForAction(&action_mock, kActionCodeError)); | 142 GetErrorCodeForAction(&action_mock, kActionCodeError)); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 attempter_.set_http_response_code(200); | 229 attempter_.set_http_response_code(200); |
| 230 InSequence s; | 230 InSequence s; |
| 231 const string kActionTypes[] = { | 231 const string kActionTypes[] = { |
| 232 OmahaRequestAction::StaticType(), | 232 OmahaRequestAction::StaticType(), |
| 233 OmahaResponseHandlerAction::StaticType(), | 233 OmahaResponseHandlerAction::StaticType(), |
| 234 FilesystemCopierAction::StaticType(), | 234 FilesystemCopierAction::StaticType(), |
| 235 FilesystemCopierAction::StaticType(), | 235 FilesystemCopierAction::StaticType(), |
| 236 OmahaRequestAction::StaticType(), | 236 OmahaRequestAction::StaticType(), |
| 237 DownloadAction::StaticType(), | 237 DownloadAction::StaticType(), |
| 238 OmahaRequestAction::StaticType(), | 238 OmahaRequestAction::StaticType(), |
| 239 FilesystemCopierAction::StaticType(), |
| 240 FilesystemCopierAction::StaticType(), |
| 239 PostinstallRunnerAction::StaticType(), | 241 PostinstallRunnerAction::StaticType(), |
| 240 OmahaRequestAction::StaticType() | 242 OmahaRequestAction::StaticType() |
| 241 }; | 243 }; |
| 242 for (size_t i = 0; i < arraysize(kActionTypes); ++i) { | 244 for (size_t i = 0; i < arraysize(kActionTypes); ++i) { |
| 243 EXPECT_CALL(*processor_, | 245 EXPECT_CALL(*processor_, |
| 244 EnqueueAction(Property(&AbstractAction::Type, | 246 EnqueueAction(Property(&AbstractAction::Type, |
| 245 kActionTypes[i]))).Times(1); | 247 kActionTypes[i]))).Times(1); |
| 246 } | 248 } |
| 247 EXPECT_CALL(*processor_, StartProcessing()).Times(1); | 249 EXPECT_CALL(*processor_, StartProcessing()).Times(1); |
| 248 | 250 |
| 249 attempter_.Update("", "", false); | 251 attempter_.Update("", "", false); |
| 250 | 252 |
| 251 EXPECT_EQ(0, attempter_.http_response_code()); | 253 EXPECT_EQ(0, attempter_.http_response_code()); |
| 252 EXPECT_EQ(&attempter_, processor_->delegate()); | 254 EXPECT_EQ(&attempter_, processor_->delegate()); |
| 253 EXPECT_EQ(arraysize(kActionTypes), attempter_.actions_.size()); | 255 EXPECT_EQ(arraysize(kActionTypes), attempter_.actions_.size()); |
| 254 for (size_t i = 0; i < arraysize(kActionTypes); ++i) { | 256 for (size_t i = 0; i < arraysize(kActionTypes); ++i) { |
| 255 EXPECT_EQ(kActionTypes[i], attempter_.actions_[i]->Type()); | 257 EXPECT_EQ(kActionTypes[i], attempter_.actions_[i]->Type()); |
| 256 } | 258 } |
| 257 EXPECT_EQ(attempter_.response_handler_action_.get(), | 259 EXPECT_EQ(attempter_.response_handler_action_.get(), |
| 258 attempter_.actions_[1].get()); | 260 attempter_.actions_[1].get()); |
| 259 DownloadAction* download_action = | 261 DownloadAction* download_action = |
| 260 dynamic_cast<DownloadAction*>(attempter_.actions_[5].get()); | 262 dynamic_cast<DownloadAction*>(attempter_.actions_[5].get()); |
| 261 ASSERT_TRUE(download_action != NULL); | 263 ASSERT_TRUE(download_action != NULL); |
| 262 EXPECT_EQ(&attempter_, download_action->delegate()); | 264 EXPECT_EQ(&attempter_, download_action->delegate()); |
| 263 EXPECT_EQ(UPDATE_STATUS_CHECKING_FOR_UPDATE, attempter_.status()); | 265 EXPECT_EQ(UPDATE_STATUS_CHECKING_FOR_UPDATE, attempter_.status()); |
| 264 } | 266 } |
| 265 | 267 |
| 266 } // namespace chromeos_update_engine | 268 } // namespace chromeos_update_engine |
| OLD | NEW |