Jay Srinivasan | 480ddfa | 2012-06-01 19:15:26 -0700 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
Darin Petkov | f42cc1c | 2010-09-01 09:03:02 -0700 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include <base/file_util.h> |
| 6 | #include <gtest/gtest.h> |
Patrick Dubroy | 7fbbe8a | 2011-08-01 17:28:22 +0200 | [diff] [blame] | 7 | #include <policy/libpolicy.h> |
| 8 | #include <policy/mock_device_policy.h> |
Darin Petkov | f42cc1c | 2010-09-01 09:03:02 -0700 | [diff] [blame] | 9 | |
| 10 | #include "update_engine/action_mock.h" |
| 11 | #include "update_engine/action_processor_mock.h" |
| 12 | #include "update_engine/filesystem_copier_action.h" |
Chris Sosa | 76a29ae | 2013-07-11 17:59:24 -0700 | [diff] [blame^] | 13 | #include "update_engine/install_plan.h" |
Andrew de los Reyes | 4516810 | 2010-11-22 11:13:50 -0800 | [diff] [blame] | 14 | #include "update_engine/mock_dbus_interface.h" |
Darin Petkov | 1b00310 | 2010-11-30 10:18:36 -0800 | [diff] [blame] | 15 | #include "update_engine/mock_http_fetcher.h" |
Jay Srinivasan | 6f6ea00 | 2012-12-14 11:26:28 -0800 | [diff] [blame] | 16 | #include "update_engine/mock_payload_state.h" |
Jay Srinivasan | 08fce04 | 2012-06-07 16:31:01 -0700 | [diff] [blame] | 17 | #include "update_engine/mock_system_state.h" |
Darin Petkov | f42cc1c | 2010-09-01 09:03:02 -0700 | [diff] [blame] | 18 | #include "update_engine/postinstall_runner_action.h" |
Jay Srinivasan | 480ddfa | 2012-06-01 19:15:26 -0700 | [diff] [blame] | 19 | #include "update_engine/prefs.h" |
Darin Petkov | 3627577 | 2010-10-01 11:40:57 -0700 | [diff] [blame] | 20 | #include "update_engine/prefs_mock.h" |
Darin Petkov | 1b00310 | 2010-11-30 10:18:36 -0800 | [diff] [blame] | 21 | #include "update_engine/test_utils.h" |
Darin Petkov | f42cc1c | 2010-09-01 09:03:02 -0700 | [diff] [blame] | 22 | #include "update_engine/update_attempter.h" |
Darin Petkov | 1b00310 | 2010-11-30 10:18:36 -0800 | [diff] [blame] | 23 | #include "update_engine/update_check_scheduler.h" |
Darin Petkov | f42cc1c | 2010-09-01 09:03:02 -0700 | [diff] [blame] | 24 | |
| 25 | using std::string; |
Darin Petkov | 3627577 | 2010-10-01 11:40:57 -0700 | [diff] [blame] | 26 | using testing::_; |
| 27 | using testing::DoAll; |
Darin Petkov | f42cc1c | 2010-09-01 09:03:02 -0700 | [diff] [blame] | 28 | using testing::InSequence; |
Darin Petkov | 2dd0109 | 2010-10-08 15:43:05 -0700 | [diff] [blame] | 29 | using testing::Ne; |
Darin Petkov | 9c096d6 | 2010-11-17 14:49:04 -0800 | [diff] [blame] | 30 | using testing::NiceMock; |
Darin Petkov | f42cc1c | 2010-09-01 09:03:02 -0700 | [diff] [blame] | 31 | using testing::Property; |
| 32 | using testing::Return; |
Darin Petkov | 3627577 | 2010-10-01 11:40:57 -0700 | [diff] [blame] | 33 | using testing::SetArgumentPointee; |
Darin Petkov | f42cc1c | 2010-09-01 09:03:02 -0700 | [diff] [blame] | 34 | |
| 35 | namespace chromeos_update_engine { |
| 36 | |
| 37 | // Test a subclass rather than the main class directly so that we can mock out |
Darin Petkov | cd1666f | 2010-09-23 09:53:44 -0700 | [diff] [blame] | 38 | // methods within the class. There're explicit unit tests for the mocked out |
Darin Petkov | f42cc1c | 2010-09-01 09:03:02 -0700 | [diff] [blame] | 39 | // methods. |
| 40 | class UpdateAttempterUnderTest : public UpdateAttempter { |
| 41 | public: |
Jay Srinivasan | 6f6ea00 | 2012-12-14 11:26:28 -0800 | [diff] [blame] | 42 | explicit UpdateAttempterUnderTest(MockSystemState* mock_system_state, |
| 43 | MockDbusGlib* dbus) |
Gilad Arnold | bf7919b | 2013-01-08 13:07:37 -0800 | [diff] [blame] | 44 | : UpdateAttempter(mock_system_state, dbus) {} |
Darin Petkov | f42cc1c | 2010-09-01 09:03:02 -0700 | [diff] [blame] | 45 | }; |
| 46 | |
| 47 | class UpdateAttempterTest : public ::testing::Test { |
| 48 | protected: |
Jay Srinivasan | 4348879 | 2012-06-19 00:25:31 -0700 | [diff] [blame] | 49 | UpdateAttempterTest() |
Jay Srinivasan | 6f6ea00 | 2012-12-14 11:26:28 -0800 | [diff] [blame] | 50 | : attempter_(&mock_system_state_, &dbus_), |
Jay Srinivasan | 4348879 | 2012-06-19 00:25:31 -0700 | [diff] [blame] | 51 | mock_connection_manager(&mock_system_state_), |
| 52 | loop_(NULL) { |
Jay Srinivasan | 6f6ea00 | 2012-12-14 11:26:28 -0800 | [diff] [blame] | 53 | mock_system_state_.set_connection_manager(&mock_connection_manager); |
Jay Srinivasan | 4348879 | 2012-06-19 00:25:31 -0700 | [diff] [blame] | 54 | } |
Darin Petkov | f42cc1c | 2010-09-01 09:03:02 -0700 | [diff] [blame] | 55 | virtual void SetUp() { |
| 56 | EXPECT_EQ(NULL, attempter_.dbus_service_); |
Jay Srinivasan | 6f6ea00 | 2012-12-14 11:26:28 -0800 | [diff] [blame] | 57 | EXPECT_TRUE(attempter_.system_state_ != NULL); |
Darin Petkov | f42cc1c | 2010-09-01 09:03:02 -0700 | [diff] [blame] | 58 | EXPECT_EQ(NULL, attempter_.update_check_scheduler_); |
| 59 | EXPECT_EQ(0, attempter_.http_response_code_); |
Chris Sosa | 4f8ee27 | 2012-11-30 13:01:54 -0800 | [diff] [blame] | 60 | EXPECT_EQ(utils::kCpuSharesNormal, attempter_.shares_); |
| 61 | EXPECT_EQ(NULL, attempter_.manage_shares_source_); |
Darin Petkov | f42cc1c | 2010-09-01 09:03:02 -0700 | [diff] [blame] | 62 | EXPECT_FALSE(attempter_.download_active_); |
| 63 | EXPECT_EQ(UPDATE_STATUS_IDLE, attempter_.status_); |
| 64 | EXPECT_EQ(0.0, attempter_.download_progress_); |
| 65 | EXPECT_EQ(0, attempter_.last_checked_time_); |
| 66 | EXPECT_EQ("0.0.0.0", attempter_.new_version_); |
Jay Srinivasan | 51dcf26 | 2012-09-13 17:24:32 -0700 | [diff] [blame] | 67 | EXPECT_EQ(0, attempter_.new_payload_size_); |
Jay Srinivasan | 55f50c2 | 2013-01-10 19:24:35 -0800 | [diff] [blame] | 68 | processor_ = new NiceMock<ActionProcessorMock>(); |
Darin Petkov | f42cc1c | 2010-09-01 09:03:02 -0700 | [diff] [blame] | 69 | attempter_.processor_.reset(processor_); // Transfers ownership. |
Jay Srinivasan | 6f6ea00 | 2012-12-14 11:26:28 -0800 | [diff] [blame] | 70 | prefs_ = mock_system_state_.mock_prefs(); |
Darin Petkov | f42cc1c | 2010-09-01 09:03:02 -0700 | [diff] [blame] | 71 | } |
| 72 | |
Patrick Dubroy | 7fbbe8a | 2011-08-01 17:28:22 +0200 | [diff] [blame] | 73 | void QuitMainLoop(); |
| 74 | static gboolean StaticQuitMainLoop(gpointer data); |
| 75 | |
Darin Petkov | e6ef2f8 | 2011-03-07 17:31:11 -0800 | [diff] [blame] | 76 | void UpdateTestStart(); |
| 77 | void UpdateTestVerify(); |
Chris Sosa | 76a29ae | 2013-07-11 17:59:24 -0700 | [diff] [blame^] | 78 | void RollbackTestStart(bool enterprise_rollback); |
| 79 | void RollbackTestVerify(); |
Darin Petkov | e6ef2f8 | 2011-03-07 17:31:11 -0800 | [diff] [blame] | 80 | static gboolean StaticUpdateTestStart(gpointer data); |
| 81 | static gboolean StaticUpdateTestVerify(gpointer data); |
Chris Sosa | 76a29ae | 2013-07-11 17:59:24 -0700 | [diff] [blame^] | 82 | static gboolean StaticRollbackTestStart(gpointer data); |
| 83 | static gboolean StaticEnterpriseRollbackTestStart(gpointer data); |
| 84 | static gboolean StaticRollbackTestVerify(gpointer data); |
Patrick Dubroy | 7fbbe8a | 2011-08-01 17:28:22 +0200 | [diff] [blame] | 85 | |
Thieu Le | 116fda3 | 2011-04-19 11:01:54 -0700 | [diff] [blame] | 86 | void PingOmahaTestStart(); |
Thieu Le | 116fda3 | 2011-04-19 11:01:54 -0700 | [diff] [blame] | 87 | static gboolean StaticPingOmahaTestStart(gpointer data); |
Patrick Dubroy | 7fbbe8a | 2011-08-01 17:28:22 +0200 | [diff] [blame] | 88 | |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 89 | void ReadChannelFromPolicyTestStart(); |
| 90 | static gboolean StaticReadChannelFromPolicyTestStart(gpointer data); |
Darin Petkov | e6ef2f8 | 2011-03-07 17:31:11 -0800 | [diff] [blame] | 91 | |
Jay Srinivasan | 0a70874 | 2012-03-20 11:26:12 -0700 | [diff] [blame] | 92 | void ReadUpdateDisabledFromPolicyTestStart(); |
| 93 | static gboolean StaticReadUpdateDisabledFromPolicyTestStart(gpointer data); |
| 94 | |
| 95 | void ReadTargetVersionPrefixFromPolicyTestStart(); |
| 96 | static gboolean StaticReadTargetVersionPrefixFromPolicyTestStart( |
| 97 | gpointer data); |
| 98 | |
Jay Srinivasan | 480ddfa | 2012-06-01 19:15:26 -0700 | [diff] [blame] | 99 | void ReadScatterFactorFromPolicyTestStart(); |
| 100 | static gboolean StaticReadScatterFactorFromPolicyTestStart( |
| 101 | gpointer data); |
| 102 | |
| 103 | void DecrementUpdateCheckCountTestStart(); |
| 104 | static gboolean StaticDecrementUpdateCheckCountTestStart( |
| 105 | gpointer data); |
| 106 | |
Jay Srinivasan | 08fce04 | 2012-06-07 16:31:01 -0700 | [diff] [blame] | 107 | void NoScatteringDoneDuringManualUpdateTestStart(); |
| 108 | static gboolean StaticNoScatteringDoneDuringManualUpdateTestStart( |
| 109 | gpointer data); |
| 110 | |
Jay Srinivasan | 55f50c2 | 2013-01-10 19:24:35 -0800 | [diff] [blame] | 111 | NiceMock<MockSystemState> mock_system_state_; |
| 112 | NiceMock<MockDbusGlib> dbus_; |
Darin Petkov | f42cc1c | 2010-09-01 09:03:02 -0700 | [diff] [blame] | 113 | UpdateAttempterUnderTest attempter_; |
Jay Srinivasan | 55f50c2 | 2013-01-10 19:24:35 -0800 | [diff] [blame] | 114 | NiceMock<ActionProcessorMock>* processor_; |
Jay Srinivasan | 6f6ea00 | 2012-12-14 11:26:28 -0800 | [diff] [blame] | 115 | NiceMock<PrefsMock>* prefs_; // shortcut to mock_system_state_->mock_prefs() |
Jay Srinivasan | 55f50c2 | 2013-01-10 19:24:35 -0800 | [diff] [blame] | 116 | NiceMock<MockConnectionManager> mock_connection_manager; |
Darin Petkov | e6ef2f8 | 2011-03-07 17:31:11 -0800 | [diff] [blame] | 117 | GMainLoop* loop_; |
Darin Petkov | f42cc1c | 2010-09-01 09:03:02 -0700 | [diff] [blame] | 118 | }; |
| 119 | |
Darin Petkov | 1b00310 | 2010-11-30 10:18:36 -0800 | [diff] [blame] | 120 | TEST_F(UpdateAttempterTest, ActionCompletedDownloadTest) { |
| 121 | scoped_ptr<MockHttpFetcher> fetcher(new MockHttpFetcher("", 0, NULL)); |
| 122 | fetcher->FailTransfer(503); // Sets the HTTP response code. |
Jay Srinivasan | 6f6ea00 | 2012-12-14 11:26:28 -0800 | [diff] [blame] | 123 | DownloadAction action(prefs_, NULL, fetcher.release()); |
| 124 | EXPECT_CALL(*prefs_, GetInt64(kPrefsDeltaUpdateFailures, _)).Times(0); |
David Zeuthen | a99981f | 2013-04-29 13:42:47 -0700 | [diff] [blame] | 125 | attempter_.ActionCompleted(NULL, &action, kErrorCodeSuccess); |
Darin Petkov | 1b00310 | 2010-11-30 10:18:36 -0800 | [diff] [blame] | 126 | EXPECT_EQ(503, attempter_.http_response_code()); |
| 127 | EXPECT_EQ(UPDATE_STATUS_FINALIZING, attempter_.status()); |
| 128 | ASSERT_TRUE(attempter_.error_event_.get() == NULL); |
| 129 | } |
| 130 | |
| 131 | TEST_F(UpdateAttempterTest, ActionCompletedErrorTest) { |
| 132 | ActionMock action; |
| 133 | EXPECT_CALL(action, Type()).WillRepeatedly(Return("ActionMock")); |
| 134 | attempter_.status_ = UPDATE_STATUS_DOWNLOADING; |
Jay Srinivasan | 6f6ea00 | 2012-12-14 11:26:28 -0800 | [diff] [blame] | 135 | EXPECT_CALL(*prefs_, GetInt64(kPrefsDeltaUpdateFailures, _)) |
Darin Petkov | 1b00310 | 2010-11-30 10:18:36 -0800 | [diff] [blame] | 136 | .WillOnce(Return(false)); |
David Zeuthen | a99981f | 2013-04-29 13:42:47 -0700 | [diff] [blame] | 137 | attempter_.ActionCompleted(NULL, &action, kErrorCodeError); |
Darin Petkov | 1b00310 | 2010-11-30 10:18:36 -0800 | [diff] [blame] | 138 | ASSERT_TRUE(attempter_.error_event_.get() != NULL); |
| 139 | } |
| 140 | |
| 141 | TEST_F(UpdateAttempterTest, ActionCompletedOmahaRequestTest) { |
| 142 | scoped_ptr<MockHttpFetcher> fetcher(new MockHttpFetcher("", 0, NULL)); |
| 143 | fetcher->FailTransfer(500); // Sets the HTTP response code. |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 144 | OmahaRequestAction action(&mock_system_state_, NULL, |
Jay Srinivasan | 6f6ea00 | 2012-12-14 11:26:28 -0800 | [diff] [blame] | 145 | fetcher.release(), false); |
Darin Petkov | 1b00310 | 2010-11-30 10:18:36 -0800 | [diff] [blame] | 146 | ObjectCollectorAction<OmahaResponse> collector_action; |
| 147 | BondActions(&action, &collector_action); |
| 148 | OmahaResponse response; |
| 149 | response.poll_interval = 234; |
| 150 | action.SetOutputObject(response); |
Gilad Arnold | bf7919b | 2013-01-08 13:07:37 -0800 | [diff] [blame] | 151 | UpdateCheckScheduler scheduler(&attempter_, &mock_system_state_); |
Darin Petkov | 1b00310 | 2010-11-30 10:18:36 -0800 | [diff] [blame] | 152 | attempter_.set_update_check_scheduler(&scheduler); |
Jay Srinivasan | 6f6ea00 | 2012-12-14 11:26:28 -0800 | [diff] [blame] | 153 | EXPECT_CALL(*prefs_, GetInt64(kPrefsDeltaUpdateFailures, _)).Times(0); |
David Zeuthen | a99981f | 2013-04-29 13:42:47 -0700 | [diff] [blame] | 154 | attempter_.ActionCompleted(NULL, &action, kErrorCodeSuccess); |
Darin Petkov | 1b00310 | 2010-11-30 10:18:36 -0800 | [diff] [blame] | 155 | EXPECT_EQ(500, attempter_.http_response_code()); |
| 156 | EXPECT_EQ(UPDATE_STATUS_IDLE, attempter_.status()); |
| 157 | EXPECT_EQ(234, scheduler.poll_interval()); |
| 158 | ASSERT_TRUE(attempter_.error_event_.get() == NULL); |
| 159 | } |
| 160 | |
Darin Petkov | cd1666f | 2010-09-23 09:53:44 -0700 | [diff] [blame] | 161 | TEST_F(UpdateAttempterTest, RunAsRootConstructWithUpdatedMarkerTest) { |
Darin Petkov | f42cc1c | 2010-09-01 09:03:02 -0700 | [diff] [blame] | 162 | extern const char* kUpdateCompletedMarker; |
| 163 | const FilePath kMarker(kUpdateCompletedMarker); |
| 164 | EXPECT_EQ(0, file_util::WriteFile(kMarker, "", 0)); |
Jay Srinivasan | 6f6ea00 | 2012-12-14 11:26:28 -0800 | [diff] [blame] | 165 | UpdateAttempterUnderTest attempter(&mock_system_state_, &dbus_); |
Darin Petkov | f42cc1c | 2010-09-01 09:03:02 -0700 | [diff] [blame] | 166 | EXPECT_EQ(UPDATE_STATUS_UPDATED_NEED_REBOOT, attempter.status()); |
| 167 | EXPECT_TRUE(file_util::Delete(kMarker, false)); |
| 168 | } |
| 169 | |
| 170 | TEST_F(UpdateAttempterTest, GetErrorCodeForActionTest) { |
David Zeuthen | a99981f | 2013-04-29 13:42:47 -0700 | [diff] [blame] | 171 | extern ErrorCode GetErrorCodeForAction(AbstractAction* action, |
| 172 | ErrorCode code); |
| 173 | EXPECT_EQ(kErrorCodeSuccess, |
| 174 | GetErrorCodeForAction(NULL, kErrorCodeSuccess)); |
Darin Petkov | f42cc1c | 2010-09-01 09:03:02 -0700 | [diff] [blame] | 175 | |
Jay Srinivasan | 6f6ea00 | 2012-12-14 11:26:28 -0800 | [diff] [blame] | 176 | MockSystemState mock_system_state; |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 177 | OmahaRequestAction omaha_request_action(&mock_system_state, NULL, |
Jay Srinivasan | 6f6ea00 | 2012-12-14 11:26:28 -0800 | [diff] [blame] | 178 | NULL, false); |
David Zeuthen | a99981f | 2013-04-29 13:42:47 -0700 | [diff] [blame] | 179 | EXPECT_EQ(kErrorCodeOmahaRequestError, |
| 180 | GetErrorCodeForAction(&omaha_request_action, kErrorCodeError)); |
Jay Srinivasan | 6f6ea00 | 2012-12-14 11:26:28 -0800 | [diff] [blame] | 181 | OmahaResponseHandlerAction omaha_response_handler_action(&mock_system_state_); |
David Zeuthen | a99981f | 2013-04-29 13:42:47 -0700 | [diff] [blame] | 182 | EXPECT_EQ(kErrorCodeOmahaResponseHandlerError, |
Darin Petkov | f42cc1c | 2010-09-01 09:03:02 -0700 | [diff] [blame] | 183 | GetErrorCodeForAction(&omaha_response_handler_action, |
David Zeuthen | a99981f | 2013-04-29 13:42:47 -0700 | [diff] [blame] | 184 | kErrorCodeError)); |
Gilad Arnold | 581c2ea | 2012-07-19 12:33:49 -0700 | [diff] [blame] | 185 | FilesystemCopierAction filesystem_copier_action(false, false); |
David Zeuthen | a99981f | 2013-04-29 13:42:47 -0700 | [diff] [blame] | 186 | EXPECT_EQ(kErrorCodeFilesystemCopierError, |
| 187 | GetErrorCodeForAction(&filesystem_copier_action, kErrorCodeError)); |
Darin Petkov | 6d5dbf6 | 2010-11-08 16:09:55 -0800 | [diff] [blame] | 188 | PostinstallRunnerAction postinstall_runner_action; |
David Zeuthen | a99981f | 2013-04-29 13:42:47 -0700 | [diff] [blame] | 189 | EXPECT_EQ(kErrorCodePostinstallRunnerError, |
Darin Petkov | f42cc1c | 2010-09-01 09:03:02 -0700 | [diff] [blame] | 190 | GetErrorCodeForAction(&postinstall_runner_action, |
David Zeuthen | a99981f | 2013-04-29 13:42:47 -0700 | [diff] [blame] | 191 | kErrorCodeError)); |
Darin Petkov | f42cc1c | 2010-09-01 09:03:02 -0700 | [diff] [blame] | 192 | ActionMock action_mock; |
| 193 | EXPECT_CALL(action_mock, Type()).Times(1).WillOnce(Return("ActionMock")); |
David Zeuthen | a99981f | 2013-04-29 13:42:47 -0700 | [diff] [blame] | 194 | EXPECT_EQ(kErrorCodeError, |
| 195 | GetErrorCodeForAction(&action_mock, kErrorCodeError)); |
Darin Petkov | f42cc1c | 2010-09-01 09:03:02 -0700 | [diff] [blame] | 196 | } |
| 197 | |
Darin Petkov | 3627577 | 2010-10-01 11:40:57 -0700 | [diff] [blame] | 198 | TEST_F(UpdateAttempterTest, DisableDeltaUpdateIfNeededTest) { |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 199 | attempter_.omaha_request_params_->set_delta_okay(true); |
Jay Srinivasan | 6f6ea00 | 2012-12-14 11:26:28 -0800 | [diff] [blame] | 200 | EXPECT_CALL(*prefs_, GetInt64(kPrefsDeltaUpdateFailures, _)) |
Darin Petkov | 3627577 | 2010-10-01 11:40:57 -0700 | [diff] [blame] | 201 | .WillOnce(Return(false)); |
| 202 | attempter_.DisableDeltaUpdateIfNeeded(); |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 203 | EXPECT_TRUE(attempter_.omaha_request_params_->delta_okay()); |
Jay Srinivasan | 6f6ea00 | 2012-12-14 11:26:28 -0800 | [diff] [blame] | 204 | EXPECT_CALL(*prefs_, GetInt64(kPrefsDeltaUpdateFailures, _)) |
Darin Petkov | 3627577 | 2010-10-01 11:40:57 -0700 | [diff] [blame] | 205 | .WillOnce(DoAll( |
| 206 | SetArgumentPointee<1>(UpdateAttempter::kMaxDeltaUpdateFailures - 1), |
| 207 | Return(true))); |
| 208 | attempter_.DisableDeltaUpdateIfNeeded(); |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 209 | EXPECT_TRUE(attempter_.omaha_request_params_->delta_okay()); |
Jay Srinivasan | 6f6ea00 | 2012-12-14 11:26:28 -0800 | [diff] [blame] | 210 | EXPECT_CALL(*prefs_, GetInt64(kPrefsDeltaUpdateFailures, _)) |
Darin Petkov | 3627577 | 2010-10-01 11:40:57 -0700 | [diff] [blame] | 211 | .WillOnce(DoAll( |
| 212 | SetArgumentPointee<1>(UpdateAttempter::kMaxDeltaUpdateFailures), |
| 213 | Return(true))); |
| 214 | attempter_.DisableDeltaUpdateIfNeeded(); |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 215 | EXPECT_FALSE(attempter_.omaha_request_params_->delta_okay()); |
Jay Srinivasan | 6f6ea00 | 2012-12-14 11:26:28 -0800 | [diff] [blame] | 216 | EXPECT_CALL(*prefs_, GetInt64(_, _)).Times(0); |
Darin Petkov | 3627577 | 2010-10-01 11:40:57 -0700 | [diff] [blame] | 217 | attempter_.DisableDeltaUpdateIfNeeded(); |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 218 | EXPECT_FALSE(attempter_.omaha_request_params_->delta_okay()); |
Darin Petkov | 3627577 | 2010-10-01 11:40:57 -0700 | [diff] [blame] | 219 | } |
| 220 | |
| 221 | TEST_F(UpdateAttempterTest, MarkDeltaUpdateFailureTest) { |
Jay Srinivasan | 6f6ea00 | 2012-12-14 11:26:28 -0800 | [diff] [blame] | 222 | EXPECT_CALL(*prefs_, GetInt64(kPrefsDeltaUpdateFailures, _)) |
Darin Petkov | 3627577 | 2010-10-01 11:40:57 -0700 | [diff] [blame] | 223 | .WillOnce(Return(false)) |
| 224 | .WillOnce(DoAll(SetArgumentPointee<1>(-1), Return(true))) |
| 225 | .WillOnce(DoAll(SetArgumentPointee<1>(1), Return(true))) |
| 226 | .WillOnce(DoAll( |
| 227 | SetArgumentPointee<1>(UpdateAttempter::kMaxDeltaUpdateFailures), |
| 228 | Return(true))); |
Jay Srinivasan | 6f6ea00 | 2012-12-14 11:26:28 -0800 | [diff] [blame] | 229 | EXPECT_CALL(*prefs_, SetInt64(Ne(kPrefsDeltaUpdateFailures), _)) |
Darin Petkov | 2dd0109 | 2010-10-08 15:43:05 -0700 | [diff] [blame] | 230 | .WillRepeatedly(Return(true)); |
Jay Srinivasan | 6f6ea00 | 2012-12-14 11:26:28 -0800 | [diff] [blame] | 231 | EXPECT_CALL(*prefs_, SetInt64(kPrefsDeltaUpdateFailures, 1)).Times(2); |
| 232 | EXPECT_CALL(*prefs_, SetInt64(kPrefsDeltaUpdateFailures, 2)).Times(1); |
| 233 | EXPECT_CALL(*prefs_, SetInt64(kPrefsDeltaUpdateFailures, |
Darin Petkov | 3627577 | 2010-10-01 11:40:57 -0700 | [diff] [blame] | 234 | UpdateAttempter::kMaxDeltaUpdateFailures + 1)) |
| 235 | .Times(1); |
| 236 | for (int i = 0; i < 4; i ++) |
| 237 | attempter_.MarkDeltaUpdateFailure(); |
| 238 | } |
| 239 | |
Darin Petkov | 1b00310 | 2010-11-30 10:18:36 -0800 | [diff] [blame] | 240 | TEST_F(UpdateAttempterTest, ScheduleErrorEventActionNoEventTest) { |
| 241 | EXPECT_CALL(*processor_, EnqueueAction(_)).Times(0); |
| 242 | EXPECT_CALL(*processor_, StartProcessing()).Times(0); |
Jay Srinivasan | 6f6ea00 | 2012-12-14 11:26:28 -0800 | [diff] [blame] | 243 | EXPECT_CALL(*mock_system_state_.mock_payload_state(), UpdateFailed(_)) |
| 244 | .Times(0); |
| 245 | OmahaResponse response; |
Jay Srinivasan | 53173b9 | 2013-05-17 17:13:01 -0700 | [diff] [blame] | 246 | string url1 = "http://url1"; |
| 247 | response.payload_urls.push_back(url1); |
Jay Srinivasan | 6f6ea00 | 2012-12-14 11:26:28 -0800 | [diff] [blame] | 248 | response.payload_urls.push_back("https://url"); |
Jay Srinivasan | 53173b9 | 2013-05-17 17:13:01 -0700 | [diff] [blame] | 249 | EXPECT_CALL(*(mock_system_state_.mock_payload_state()), GetCurrentUrl()) |
| 250 | .WillRepeatedly(Return(url1)); |
Jay Srinivasan | 6f6ea00 | 2012-12-14 11:26:28 -0800 | [diff] [blame] | 251 | mock_system_state_.mock_payload_state()->SetResponse(response); |
Darin Petkov | 1b00310 | 2010-11-30 10:18:36 -0800 | [diff] [blame] | 252 | attempter_.ScheduleErrorEventAction(); |
Jay Srinivasan | 53173b9 | 2013-05-17 17:13:01 -0700 | [diff] [blame] | 253 | EXPECT_EQ(url1, mock_system_state_.mock_payload_state()->GetCurrentUrl()); |
Darin Petkov | 1b00310 | 2010-11-30 10:18:36 -0800 | [diff] [blame] | 254 | } |
| 255 | |
| 256 | TEST_F(UpdateAttempterTest, ScheduleErrorEventActionTest) { |
| 257 | EXPECT_CALL(*processor_, |
| 258 | EnqueueAction(Property(&AbstractAction::Type, |
| 259 | OmahaRequestAction::StaticType()))) |
| 260 | .Times(1); |
| 261 | EXPECT_CALL(*processor_, StartProcessing()).Times(1); |
David Zeuthen | a99981f | 2013-04-29 13:42:47 -0700 | [diff] [blame] | 262 | ErrorCode err = kErrorCodeError; |
Jay Srinivasan | 2b5a0f0 | 2012-12-19 17:25:56 -0800 | [diff] [blame] | 263 | EXPECT_CALL(*mock_system_state_.mock_payload_state(), UpdateFailed(err)); |
Darin Petkov | 1b00310 | 2010-11-30 10:18:36 -0800 | [diff] [blame] | 264 | attempter_.error_event_.reset(new OmahaEvent(OmahaEvent::kTypeUpdateComplete, |
| 265 | OmahaEvent::kResultError, |
Jay Srinivasan | 6f6ea00 | 2012-12-14 11:26:28 -0800 | [diff] [blame] | 266 | err)); |
Darin Petkov | 1b00310 | 2010-11-30 10:18:36 -0800 | [diff] [blame] | 267 | attempter_.ScheduleErrorEventAction(); |
| 268 | EXPECT_EQ(UPDATE_STATUS_REPORTING_ERROR_EVENT, attempter_.status()); |
| 269 | } |
| 270 | |
Darin Petkov | f42cc1c | 2010-09-01 09:03:02 -0700 | [diff] [blame] | 271 | TEST_F(UpdateAttempterTest, UpdateStatusToStringTest) { |
| 272 | extern const char* UpdateStatusToString(UpdateStatus); |
| 273 | EXPECT_STREQ("UPDATE_STATUS_IDLE", UpdateStatusToString(UPDATE_STATUS_IDLE)); |
| 274 | EXPECT_STREQ("UPDATE_STATUS_CHECKING_FOR_UPDATE", |
| 275 | UpdateStatusToString(UPDATE_STATUS_CHECKING_FOR_UPDATE)); |
| 276 | EXPECT_STREQ("UPDATE_STATUS_UPDATE_AVAILABLE", |
| 277 | UpdateStatusToString(UPDATE_STATUS_UPDATE_AVAILABLE)); |
| 278 | EXPECT_STREQ("UPDATE_STATUS_DOWNLOADING", |
| 279 | UpdateStatusToString(UPDATE_STATUS_DOWNLOADING)); |
| 280 | EXPECT_STREQ("UPDATE_STATUS_VERIFYING", |
| 281 | UpdateStatusToString(UPDATE_STATUS_VERIFYING)); |
| 282 | EXPECT_STREQ("UPDATE_STATUS_FINALIZING", |
| 283 | UpdateStatusToString(UPDATE_STATUS_FINALIZING)); |
| 284 | EXPECT_STREQ("UPDATE_STATUS_UPDATED_NEED_REBOOT", |
| 285 | UpdateStatusToString(UPDATE_STATUS_UPDATED_NEED_REBOOT)); |
| 286 | EXPECT_STREQ("UPDATE_STATUS_REPORTING_ERROR_EVENT", |
| 287 | UpdateStatusToString(UPDATE_STATUS_REPORTING_ERROR_EVENT)); |
| 288 | EXPECT_STREQ("unknown status", |
| 289 | UpdateStatusToString(static_cast<UpdateStatus>(-1))); |
| 290 | } |
| 291 | |
Patrick Dubroy | 7fbbe8a | 2011-08-01 17:28:22 +0200 | [diff] [blame] | 292 | void UpdateAttempterTest::QuitMainLoop() { |
| 293 | g_main_loop_quit(loop_); |
| 294 | } |
| 295 | |
| 296 | gboolean UpdateAttempterTest::StaticQuitMainLoop(gpointer data) { |
| 297 | reinterpret_cast<UpdateAttempterTest*>(data)->QuitMainLoop(); |
| 298 | return FALSE; |
| 299 | } |
| 300 | |
Darin Petkov | e6ef2f8 | 2011-03-07 17:31:11 -0800 | [diff] [blame] | 301 | gboolean UpdateAttempterTest::StaticUpdateTestStart(gpointer data) { |
| 302 | reinterpret_cast<UpdateAttempterTest*>(data)->UpdateTestStart(); |
| 303 | return FALSE; |
| 304 | } |
| 305 | |
| 306 | gboolean UpdateAttempterTest::StaticUpdateTestVerify(gpointer data) { |
| 307 | reinterpret_cast<UpdateAttempterTest*>(data)->UpdateTestVerify(); |
| 308 | return FALSE; |
| 309 | } |
| 310 | |
Chris Sosa | 76a29ae | 2013-07-11 17:59:24 -0700 | [diff] [blame^] | 311 | gboolean UpdateAttempterTest::StaticRollbackTestStart(gpointer data) { |
| 312 | reinterpret_cast<UpdateAttempterTest*>(data)->RollbackTestStart(false); |
| 313 | return FALSE; |
| 314 | } |
| 315 | |
| 316 | gboolean UpdateAttempterTest::StaticEnterpriseRollbackTestStart(gpointer data) { |
| 317 | reinterpret_cast<UpdateAttempterTest*>(data)->RollbackTestStart(true); |
| 318 | return FALSE; |
| 319 | } |
| 320 | |
| 321 | gboolean UpdateAttempterTest::StaticRollbackTestVerify(gpointer data) { |
| 322 | reinterpret_cast<UpdateAttempterTest*>(data)->RollbackTestVerify(); |
| 323 | return FALSE; |
| 324 | } |
| 325 | |
Thieu Le | 116fda3 | 2011-04-19 11:01:54 -0700 | [diff] [blame] | 326 | gboolean UpdateAttempterTest::StaticPingOmahaTestStart(gpointer data) { |
| 327 | reinterpret_cast<UpdateAttempterTest*>(data)->PingOmahaTestStart(); |
| 328 | return FALSE; |
| 329 | } |
| 330 | |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 331 | gboolean UpdateAttempterTest::StaticReadChannelFromPolicyTestStart( |
Patrick Dubroy | 7fbbe8a | 2011-08-01 17:28:22 +0200 | [diff] [blame] | 332 | gpointer data) { |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 333 | UpdateAttempterTest* ua_test = reinterpret_cast<UpdateAttempterTest*>(data); |
| 334 | ua_test->ReadChannelFromPolicyTestStart(); |
Thieu Le | 116fda3 | 2011-04-19 11:01:54 -0700 | [diff] [blame] | 335 | return FALSE; |
| 336 | } |
| 337 | |
Jay Srinivasan | 0a70874 | 2012-03-20 11:26:12 -0700 | [diff] [blame] | 338 | gboolean UpdateAttempterTest::StaticReadUpdateDisabledFromPolicyTestStart( |
| 339 | gpointer data) { |
| 340 | UpdateAttempterTest* ua_test = reinterpret_cast<UpdateAttempterTest*>(data); |
| 341 | ua_test->ReadUpdateDisabledFromPolicyTestStart(); |
| 342 | return FALSE; |
| 343 | } |
| 344 | |
| 345 | gboolean UpdateAttempterTest::StaticReadTargetVersionPrefixFromPolicyTestStart( |
| 346 | gpointer data) { |
| 347 | UpdateAttempterTest* ua_test = reinterpret_cast<UpdateAttempterTest*>(data); |
| 348 | ua_test->ReadTargetVersionPrefixFromPolicyTestStart(); |
| 349 | return FALSE; |
| 350 | } |
| 351 | |
Jay Srinivasan | 480ddfa | 2012-06-01 19:15:26 -0700 | [diff] [blame] | 352 | gboolean UpdateAttempterTest::StaticReadScatterFactorFromPolicyTestStart( |
| 353 | gpointer data) { |
| 354 | UpdateAttempterTest* ua_test = reinterpret_cast<UpdateAttempterTest*>(data); |
| 355 | ua_test->ReadScatterFactorFromPolicyTestStart(); |
| 356 | return FALSE; |
| 357 | } |
| 358 | |
| 359 | gboolean UpdateAttempterTest::StaticDecrementUpdateCheckCountTestStart( |
| 360 | gpointer data) { |
| 361 | UpdateAttempterTest* ua_test = reinterpret_cast<UpdateAttempterTest*>(data); |
| 362 | ua_test->DecrementUpdateCheckCountTestStart(); |
| 363 | return FALSE; |
| 364 | } |
| 365 | |
Jay Srinivasan | 08fce04 | 2012-06-07 16:31:01 -0700 | [diff] [blame] | 366 | gboolean UpdateAttempterTest::StaticNoScatteringDoneDuringManualUpdateTestStart( |
| 367 | gpointer data) { |
| 368 | UpdateAttempterTest* ua_test = reinterpret_cast<UpdateAttempterTest*>(data); |
| 369 | ua_test->NoScatteringDoneDuringManualUpdateTestStart(); |
| 370 | return FALSE; |
| 371 | } |
| 372 | |
Darin Petkov | e6ef2f8 | 2011-03-07 17:31:11 -0800 | [diff] [blame] | 373 | namespace { |
Chris Sosa | 76a29ae | 2013-07-11 17:59:24 -0700 | [diff] [blame^] | 374 | // Actions that will be built as part of an update check. |
| 375 | const string kUpdateActionTypes[] = { |
Darin Petkov | e6ef2f8 | 2011-03-07 17:31:11 -0800 | [diff] [blame] | 376 | OmahaRequestAction::StaticType(), |
| 377 | OmahaResponseHandlerAction::StaticType(), |
| 378 | FilesystemCopierAction::StaticType(), |
| 379 | FilesystemCopierAction::StaticType(), |
| 380 | OmahaRequestAction::StaticType(), |
| 381 | DownloadAction::StaticType(), |
| 382 | OmahaRequestAction::StaticType(), |
| 383 | FilesystemCopierAction::StaticType(), |
| 384 | FilesystemCopierAction::StaticType(), |
| 385 | PostinstallRunnerAction::StaticType(), |
| 386 | OmahaRequestAction::StaticType() |
| 387 | }; |
Chris Sosa | 76a29ae | 2013-07-11 17:59:24 -0700 | [diff] [blame^] | 388 | |
| 389 | // Actions that will be built as part of a user-initiated rollback. |
| 390 | const string kRollbackActionTypes[] = { |
| 391 | InstallPlanAction::StaticType(), |
| 392 | PostinstallRunnerAction::StaticType(), |
| 393 | }; |
| 394 | |
Darin Petkov | e6ef2f8 | 2011-03-07 17:31:11 -0800 | [diff] [blame] | 395 | } // namespace {} |
| 396 | |
| 397 | void UpdateAttempterTest::UpdateTestStart() { |
Darin Petkov | f42cc1c | 2010-09-01 09:03:02 -0700 | [diff] [blame] | 398 | attempter_.set_http_response_code(200); |
| 399 | InSequence s; |
Chris Sosa | 76a29ae | 2013-07-11 17:59:24 -0700 | [diff] [blame^] | 400 | for (size_t i = 0; i < arraysize(kUpdateActionTypes); ++i) { |
Darin Petkov | f42cc1c | 2010-09-01 09:03:02 -0700 | [diff] [blame] | 401 | EXPECT_CALL(*processor_, |
| 402 | EnqueueAction(Property(&AbstractAction::Type, |
Chris Sosa | 76a29ae | 2013-07-11 17:59:24 -0700 | [diff] [blame^] | 403 | kUpdateActionTypes[i]))).Times(1); |
Darin Petkov | f42cc1c | 2010-09-01 09:03:02 -0700 | [diff] [blame] | 404 | } |
| 405 | EXPECT_CALL(*processor_, StartProcessing()).Times(1); |
| 406 | |
Gilad Arnold | b92f0df | 2013-01-10 16:32:45 -0800 | [diff] [blame] | 407 | attempter_.Update("", "", false, false, false); |
Darin Petkov | e6ef2f8 | 2011-03-07 17:31:11 -0800 | [diff] [blame] | 408 | g_idle_add(&StaticUpdateTestVerify, this); |
| 409 | } |
Darin Petkov | f42cc1c | 2010-09-01 09:03:02 -0700 | [diff] [blame] | 410 | |
Darin Petkov | e6ef2f8 | 2011-03-07 17:31:11 -0800 | [diff] [blame] | 411 | void UpdateAttempterTest::UpdateTestVerify() { |
Darin Petkov | f42cc1c | 2010-09-01 09:03:02 -0700 | [diff] [blame] | 412 | EXPECT_EQ(0, attempter_.http_response_code()); |
| 413 | EXPECT_EQ(&attempter_, processor_->delegate()); |
Chris Sosa | 76a29ae | 2013-07-11 17:59:24 -0700 | [diff] [blame^] | 414 | EXPECT_EQ(arraysize(kUpdateActionTypes), attempter_.actions_.size()); |
| 415 | for (size_t i = 0; i < arraysize(kUpdateActionTypes); ++i) { |
| 416 | EXPECT_EQ(kUpdateActionTypes[i], attempter_.actions_[i]->Type()); |
Darin Petkov | f42cc1c | 2010-09-01 09:03:02 -0700 | [diff] [blame] | 417 | } |
| 418 | EXPECT_EQ(attempter_.response_handler_action_.get(), |
| 419 | attempter_.actions_[1].get()); |
| 420 | DownloadAction* download_action = |
| 421 | dynamic_cast<DownloadAction*>(attempter_.actions_[5].get()); |
| 422 | ASSERT_TRUE(download_action != NULL); |
| 423 | EXPECT_EQ(&attempter_, download_action->delegate()); |
| 424 | EXPECT_EQ(UPDATE_STATUS_CHECKING_FOR_UPDATE, attempter_.status()); |
Darin Petkov | e6ef2f8 | 2011-03-07 17:31:11 -0800 | [diff] [blame] | 425 | g_main_loop_quit(loop_); |
| 426 | } |
| 427 | |
Chris Sosa | 76a29ae | 2013-07-11 17:59:24 -0700 | [diff] [blame^] | 428 | void UpdateAttempterTest::RollbackTestStart(bool enterprise_rollback) { |
| 429 | // Create a device policy so that we can change settings. |
| 430 | policy::MockDevicePolicy* device_policy = new policy::MockDevicePolicy(); |
| 431 | attempter_.policy_provider_.reset(new policy::PolicyProvider(device_policy)); |
| 432 | |
| 433 | EXPECT_CALL(*device_policy, LoadPolicy()).WillRepeatedly(Return(true)); |
| 434 | EXPECT_CALL(mock_system_state_, device_policy()).WillRepeatedly( |
| 435 | Return(device_policy)); |
| 436 | |
| 437 | string install_path = "/dev/sda3"; |
| 438 | |
| 439 | // Non-enterprise enrolled device account with an owner in the device policy. |
| 440 | if (!enterprise_rollback) { |
| 441 | EXPECT_CALL(*device_policy, GetOwner(_)).WillOnce( |
| 442 | DoAll(SetArgumentPointee<0>(std::string("fake.mail@fake.com")), |
| 443 | Return(true))); |
| 444 | |
| 445 | InSequence s; |
| 446 | for (size_t i = 0; i < arraysize(kRollbackActionTypes); ++i) { |
| 447 | EXPECT_CALL(*processor_, |
| 448 | EnqueueAction(Property(&AbstractAction::Type, |
| 449 | kRollbackActionTypes[i]))).Times(1); |
| 450 | } |
| 451 | EXPECT_CALL(*processor_, StartProcessing()).Times(1); |
| 452 | |
| 453 | EXPECT_TRUE(attempter_.Rollback(true, &install_path)); |
| 454 | g_idle_add(&StaticRollbackTestVerify, this); |
| 455 | } else { |
| 456 | // We return an empty owner as this is an enterprise. |
| 457 | EXPECT_CALL(*device_policy, GetOwner(_)).WillOnce( |
| 458 | DoAll(SetArgumentPointee<0>(std::string("")), |
| 459 | Return(true))); |
| 460 | |
| 461 | // We do not currently support rollbacks for enterprises. |
| 462 | EXPECT_FALSE(attempter_.Rollback(true, &install_path)); |
| 463 | g_main_loop_quit(loop_); |
| 464 | } |
| 465 | } |
| 466 | |
| 467 | void UpdateAttempterTest::RollbackTestVerify() { |
| 468 | // Verifies the actions that were enqueued. |
| 469 | EXPECT_EQ(&attempter_, processor_->delegate()); |
| 470 | EXPECT_EQ(arraysize(kRollbackActionTypes), attempter_.actions_.size()); |
| 471 | for (size_t i = 0; i < arraysize(kRollbackActionTypes); ++i) { |
| 472 | EXPECT_EQ(kRollbackActionTypes[i], attempter_.actions_[i]->Type()); |
| 473 | } |
| 474 | EXPECT_EQ(UPDATE_STATUS_ATTEMPTING_ROLLBACK, attempter_.status()); |
| 475 | InstallPlanAction* install_plan_action = |
| 476 | dynamic_cast<InstallPlanAction*>(attempter_.actions_[0].get()); |
| 477 | InstallPlan* install_plan = install_plan_action->install_plan(); |
| 478 | EXPECT_EQ(install_plan->install_path, string("/dev/sda3")); |
| 479 | EXPECT_EQ(install_plan->kernel_install_path, string("/dev/sda2")); |
| 480 | EXPECT_EQ(install_plan->powerwash_required, true); |
| 481 | g_main_loop_quit(loop_); |
| 482 | } |
| 483 | |
Darin Petkov | e6ef2f8 | 2011-03-07 17:31:11 -0800 | [diff] [blame] | 484 | TEST_F(UpdateAttempterTest, UpdateTest) { |
| 485 | loop_ = g_main_loop_new(g_main_context_default(), FALSE); |
| 486 | g_idle_add(&StaticUpdateTestStart, this); |
| 487 | g_main_loop_run(loop_); |
| 488 | g_main_loop_unref(loop_); |
| 489 | loop_ = NULL; |
Darin Petkov | f42cc1c | 2010-09-01 09:03:02 -0700 | [diff] [blame] | 490 | } |
| 491 | |
Chris Sosa | 76a29ae | 2013-07-11 17:59:24 -0700 | [diff] [blame^] | 492 | TEST_F(UpdateAttempterTest, RollbackTest) { |
| 493 | loop_ = g_main_loop_new(g_main_context_default(), FALSE); |
| 494 | g_idle_add(&StaticRollbackTestStart, this); |
| 495 | g_main_loop_run(loop_); |
| 496 | g_main_loop_unref(loop_); |
| 497 | loop_ = NULL; |
| 498 | } |
| 499 | |
| 500 | TEST_F(UpdateAttempterTest, EnterpriseRollbackTest) { |
| 501 | loop_ = g_main_loop_new(g_main_context_default(), FALSE); |
| 502 | g_idle_add(&StaticEnterpriseRollbackTestStart, this); |
| 503 | g_main_loop_run(loop_); |
| 504 | g_main_loop_unref(loop_); |
| 505 | loop_ = NULL; |
| 506 | } |
| 507 | |
Thieu Le | 116fda3 | 2011-04-19 11:01:54 -0700 | [diff] [blame] | 508 | void UpdateAttempterTest::PingOmahaTestStart() { |
| 509 | EXPECT_CALL(*processor_, |
| 510 | EnqueueAction(Property(&AbstractAction::Type, |
| 511 | OmahaRequestAction::StaticType()))) |
| 512 | .Times(1); |
| 513 | EXPECT_CALL(*processor_, StartProcessing()).Times(1); |
| 514 | attempter_.PingOmaha(); |
Patrick Dubroy | 7fbbe8a | 2011-08-01 17:28:22 +0200 | [diff] [blame] | 515 | g_idle_add(&StaticQuitMainLoop, this); |
Thieu Le | 116fda3 | 2011-04-19 11:01:54 -0700 | [diff] [blame] | 516 | } |
| 517 | |
| 518 | TEST_F(UpdateAttempterTest, PingOmahaTest) { |
Gilad Arnold | bf7919b | 2013-01-08 13:07:37 -0800 | [diff] [blame] | 519 | UpdateCheckScheduler scheduler(&attempter_, &mock_system_state_); |
Thieu Le | 116fda3 | 2011-04-19 11:01:54 -0700 | [diff] [blame] | 520 | scheduler.enabled_ = true; |
Andrew de los Reyes | e05fc28 | 2011-06-02 09:50:08 -0700 | [diff] [blame] | 521 | EXPECT_FALSE(scheduler.scheduled_); |
Thieu Le | 116fda3 | 2011-04-19 11:01:54 -0700 | [diff] [blame] | 522 | attempter_.set_update_check_scheduler(&scheduler); |
| 523 | loop_ = g_main_loop_new(g_main_context_default(), FALSE); |
| 524 | g_idle_add(&StaticPingOmahaTestStart, this); |
| 525 | g_main_loop_run(loop_); |
| 526 | g_main_loop_unref(loop_); |
| 527 | loop_ = NULL; |
| 528 | EXPECT_EQ(UPDATE_STATUS_UPDATED_NEED_REBOOT, attempter_.status()); |
| 529 | EXPECT_EQ(true, scheduler.scheduled_); |
| 530 | } |
| 531 | |
Darin Petkov | 18c7bce | 2011-06-16 14:07:00 -0700 | [diff] [blame] | 532 | TEST_F(UpdateAttempterTest, CreatePendingErrorEventTest) { |
| 533 | ActionMock action; |
David Zeuthen | a99981f | 2013-04-29 13:42:47 -0700 | [diff] [blame] | 534 | const ErrorCode kCode = kErrorCodeDownloadTransferError; |
Darin Petkov | 18c7bce | 2011-06-16 14:07:00 -0700 | [diff] [blame] | 535 | attempter_.CreatePendingErrorEvent(&action, kCode); |
| 536 | ASSERT_TRUE(attempter_.error_event_.get() != NULL); |
| 537 | EXPECT_EQ(OmahaEvent::kTypeUpdateComplete, attempter_.error_event_->type); |
| 538 | EXPECT_EQ(OmahaEvent::kResultError, attempter_.error_event_->result); |
David Zeuthen | a99981f | 2013-04-29 13:42:47 -0700 | [diff] [blame] | 539 | EXPECT_EQ(kCode | kErrorCodeTestOmahaUrlFlag, |
Jay Srinivasan | 55f50c2 | 2013-01-10 19:24:35 -0800 | [diff] [blame] | 540 | attempter_.error_event_->error_code); |
Darin Petkov | 18c7bce | 2011-06-16 14:07:00 -0700 | [diff] [blame] | 541 | } |
| 542 | |
| 543 | TEST_F(UpdateAttempterTest, CreatePendingErrorEventResumedTest) { |
| 544 | OmahaResponseHandlerAction *response_action = |
Jay Srinivasan | 6f6ea00 | 2012-12-14 11:26:28 -0800 | [diff] [blame] | 545 | new OmahaResponseHandlerAction(&mock_system_state_); |
Darin Petkov | 18c7bce | 2011-06-16 14:07:00 -0700 | [diff] [blame] | 546 | response_action->install_plan_.is_resume = true; |
| 547 | attempter_.response_handler_action_.reset(response_action); |
| 548 | ActionMock action; |
David Zeuthen | a99981f | 2013-04-29 13:42:47 -0700 | [diff] [blame] | 549 | const ErrorCode kCode = kErrorCodeInstallDeviceOpenError; |
Darin Petkov | 18c7bce | 2011-06-16 14:07:00 -0700 | [diff] [blame] | 550 | attempter_.CreatePendingErrorEvent(&action, kCode); |
| 551 | ASSERT_TRUE(attempter_.error_event_.get() != NULL); |
| 552 | EXPECT_EQ(OmahaEvent::kTypeUpdateComplete, attempter_.error_event_->type); |
| 553 | EXPECT_EQ(OmahaEvent::kResultError, attempter_.error_event_->result); |
David Zeuthen | a99981f | 2013-04-29 13:42:47 -0700 | [diff] [blame] | 554 | EXPECT_EQ(kCode | kErrorCodeResumedFlag | kErrorCodeTestOmahaUrlFlag, |
Darin Petkov | 18c7bce | 2011-06-16 14:07:00 -0700 | [diff] [blame] | 555 | attempter_.error_event_->error_code); |
| 556 | } |
| 557 | |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 558 | TEST_F(UpdateAttempterTest, ReadChannelFromPolicy) { |
Patrick Dubroy | 7fbbe8a | 2011-08-01 17:28:22 +0200 | [diff] [blame] | 559 | loop_ = g_main_loop_new(g_main_context_default(), FALSE); |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 560 | g_idle_add(&StaticReadChannelFromPolicyTestStart, this); |
Patrick Dubroy | 7fbbe8a | 2011-08-01 17:28:22 +0200 | [diff] [blame] | 561 | g_main_loop_run(loop_); |
| 562 | g_main_loop_unref(loop_); |
| 563 | loop_ = NULL; |
| 564 | } |
| 565 | |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 566 | void UpdateAttempterTest::ReadChannelFromPolicyTestStart() { |
| 567 | // Tests that the update channel (aka release channel) is properly fetched |
Patrick Dubroy | 7fbbe8a | 2011-08-01 17:28:22 +0200 | [diff] [blame] | 568 | // from the device policy. |
| 569 | |
| 570 | policy::MockDevicePolicy* device_policy = new policy::MockDevicePolicy(); |
| 571 | attempter_.policy_provider_.reset(new policy::PolicyProvider(device_policy)); |
| 572 | |
| 573 | EXPECT_CALL(*device_policy, LoadPolicy()).WillRepeatedly(Return(true)); |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 574 | EXPECT_CALL(mock_system_state_, device_policy()).WillRepeatedly( |
| 575 | Return(device_policy)); |
Patrick Dubroy | 7fbbe8a | 2011-08-01 17:28:22 +0200 | [diff] [blame] | 576 | |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 577 | EXPECT_CALL(*device_policy, GetReleaseChannelDelegated(_)).WillRepeatedly( |
| 578 | DoAll(SetArgumentPointee<0>(bool(false)), |
| 579 | Return(true))); |
Patrick Dubroy | 7fbbe8a | 2011-08-01 17:28:22 +0200 | [diff] [blame] | 580 | |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 581 | EXPECT_CALL(*device_policy, GetReleaseChannel(_)).WillRepeatedly( |
| 582 | DoAll(SetArgumentPointee<0>(std::string("beta-channel")), |
| 583 | Return(true))); |
| 584 | |
| 585 | attempter_.omaha_request_params_->set_root("./UpdateAttempterTest"); |
Gilad Arnold | b92f0df | 2013-01-10 16:32:45 -0800 | [diff] [blame] | 586 | attempter_.Update("", "", false, false, false); |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 587 | EXPECT_EQ("beta-channel", |
| 588 | attempter_.omaha_request_params_->target_channel()); |
Patrick Dubroy | 7fbbe8a | 2011-08-01 17:28:22 +0200 | [diff] [blame] | 589 | |
| 590 | g_idle_add(&StaticQuitMainLoop, this); |
| 591 | } |
| 592 | |
Jay Srinivasan | 0a70874 | 2012-03-20 11:26:12 -0700 | [diff] [blame] | 593 | TEST_F(UpdateAttempterTest, ReadUpdateDisabledFromPolicy) { |
| 594 | loop_ = g_main_loop_new(g_main_context_default(), FALSE); |
| 595 | g_idle_add(&StaticReadUpdateDisabledFromPolicyTestStart, this); |
| 596 | g_main_loop_run(loop_); |
| 597 | g_main_loop_unref(loop_); |
| 598 | loop_ = NULL; |
| 599 | } |
| 600 | |
| 601 | void UpdateAttempterTest::ReadUpdateDisabledFromPolicyTestStart() { |
| 602 | // Tests that the update_disbled flag is properly fetched |
| 603 | // from the device policy. |
| 604 | |
| 605 | policy::MockDevicePolicy* device_policy = new policy::MockDevicePolicy(); |
| 606 | attempter_.policy_provider_.reset(new policy::PolicyProvider(device_policy)); |
| 607 | |
| 608 | EXPECT_CALL(*device_policy, LoadPolicy()).WillRepeatedly(Return(true)); |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 609 | EXPECT_CALL(mock_system_state_, device_policy()).WillRepeatedly( |
| 610 | Return(device_policy)); |
Jay Srinivasan | 0a70874 | 2012-03-20 11:26:12 -0700 | [diff] [blame] | 611 | |
| 612 | EXPECT_CALL(*device_policy, GetUpdateDisabled(_)) |
| 613 | .WillRepeatedly(DoAll( |
| 614 | SetArgumentPointee<0>(true), |
| 615 | Return(true))); |
| 616 | |
Gilad Arnold | b92f0df | 2013-01-10 16:32:45 -0800 | [diff] [blame] | 617 | attempter_.Update("", "", false, false, false); |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 618 | EXPECT_TRUE(attempter_.omaha_request_params_->update_disabled()); |
Jay Srinivasan | 0a70874 | 2012-03-20 11:26:12 -0700 | [diff] [blame] | 619 | |
| 620 | g_idle_add(&StaticQuitMainLoop, this); |
| 621 | } |
| 622 | |
| 623 | TEST_F(UpdateAttempterTest, ReadTargetVersionPrefixFromPolicy) { |
| 624 | loop_ = g_main_loop_new(g_main_context_default(), FALSE); |
| 625 | g_idle_add(&StaticReadTargetVersionPrefixFromPolicyTestStart, this); |
| 626 | g_main_loop_run(loop_); |
| 627 | g_main_loop_unref(loop_); |
| 628 | loop_ = NULL; |
| 629 | } |
| 630 | |
| 631 | void UpdateAttempterTest::ReadTargetVersionPrefixFromPolicyTestStart() { |
| 632 | // Tests that the target_version_prefix value is properly fetched |
| 633 | // from the device policy. |
| 634 | |
| 635 | const std::string target_version_prefix = "1412."; |
| 636 | |
| 637 | policy::MockDevicePolicy* device_policy = new policy::MockDevicePolicy(); |
| 638 | attempter_.policy_provider_.reset(new policy::PolicyProvider(device_policy)); |
| 639 | |
| 640 | EXPECT_CALL(*device_policy, LoadPolicy()).WillRepeatedly(Return(true)); |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 641 | EXPECT_CALL(mock_system_state_, device_policy()).WillRepeatedly( |
| 642 | Return(device_policy)); |
Jay Srinivasan | 0a70874 | 2012-03-20 11:26:12 -0700 | [diff] [blame] | 643 | |
| 644 | EXPECT_CALL(*device_policy, GetTargetVersionPrefix(_)) |
| 645 | .WillRepeatedly(DoAll( |
| 646 | SetArgumentPointee<0>(target_version_prefix), |
| 647 | Return(true))); |
| 648 | |
Gilad Arnold | b92f0df | 2013-01-10 16:32:45 -0800 | [diff] [blame] | 649 | attempter_.Update("", "", false, false, false); |
Jay Srinivasan | 0a70874 | 2012-03-20 11:26:12 -0700 | [diff] [blame] | 650 | EXPECT_EQ(target_version_prefix.c_str(), |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 651 | attempter_.omaha_request_params_->target_version_prefix()); |
Jay Srinivasan | 0a70874 | 2012-03-20 11:26:12 -0700 | [diff] [blame] | 652 | |
| 653 | g_idle_add(&StaticQuitMainLoop, this); |
| 654 | } |
| 655 | |
| 656 | |
Jay Srinivasan | 480ddfa | 2012-06-01 19:15:26 -0700 | [diff] [blame] | 657 | TEST_F(UpdateAttempterTest, ReadScatterFactorFromPolicy) { |
| 658 | loop_ = g_main_loop_new(g_main_context_default(), FALSE); |
| 659 | g_idle_add(&StaticReadScatterFactorFromPolicyTestStart, this); |
| 660 | g_main_loop_run(loop_); |
| 661 | g_main_loop_unref(loop_); |
| 662 | loop_ = NULL; |
| 663 | } |
| 664 | |
| 665 | // Tests that the scatter_factor_in_seconds value is properly fetched |
| 666 | // from the device policy. |
| 667 | void UpdateAttempterTest::ReadScatterFactorFromPolicyTestStart() { |
| 668 | int64 scatter_factor_in_seconds = 36000; |
| 669 | |
| 670 | policy::MockDevicePolicy* device_policy = new policy::MockDevicePolicy(); |
| 671 | attempter_.policy_provider_.reset(new policy::PolicyProvider(device_policy)); |
| 672 | |
| 673 | EXPECT_CALL(*device_policy, LoadPolicy()).WillRepeatedly(Return(true)); |
Jay Srinivasan | 6f6ea00 | 2012-12-14 11:26:28 -0800 | [diff] [blame] | 674 | EXPECT_CALL(mock_system_state_, device_policy()).WillRepeatedly( |
Jay Srinivasan | 21be075 | 2012-07-25 15:44:56 -0700 | [diff] [blame] | 675 | Return(device_policy)); |
Jay Srinivasan | 480ddfa | 2012-06-01 19:15:26 -0700 | [diff] [blame] | 676 | |
| 677 | EXPECT_CALL(*device_policy, GetScatterFactorInSeconds(_)) |
| 678 | .WillRepeatedly(DoAll( |
| 679 | SetArgumentPointee<0>(scatter_factor_in_seconds), |
| 680 | Return(true))); |
| 681 | |
Gilad Arnold | b92f0df | 2013-01-10 16:32:45 -0800 | [diff] [blame] | 682 | attempter_.Update("", "", false, false, false); |
Jay Srinivasan | 480ddfa | 2012-06-01 19:15:26 -0700 | [diff] [blame] | 683 | EXPECT_EQ(scatter_factor_in_seconds, attempter_.scatter_factor_.InSeconds()); |
| 684 | |
| 685 | g_idle_add(&StaticQuitMainLoop, this); |
| 686 | } |
| 687 | |
| 688 | TEST_F(UpdateAttempterTest, DecrementUpdateCheckCountTest) { |
| 689 | loop_ = g_main_loop_new(g_main_context_default(), FALSE); |
| 690 | g_idle_add(&StaticDecrementUpdateCheckCountTestStart, this); |
| 691 | g_main_loop_run(loop_); |
| 692 | g_main_loop_unref(loop_); |
| 693 | loop_ = NULL; |
| 694 | } |
| 695 | |
| 696 | void UpdateAttempterTest::DecrementUpdateCheckCountTestStart() { |
| 697 | // Tests that the scatter_factor_in_seconds value is properly fetched |
| 698 | // from the device policy and is decremented if value > 0. |
| 699 | int64 initial_value = 5; |
| 700 | Prefs prefs; |
| 701 | attempter_.prefs_ = &prefs; |
| 702 | |
Jay Srinivasan | 08fce04 | 2012-06-07 16:31:01 -0700 | [diff] [blame] | 703 | EXPECT_CALL(mock_system_state_, |
| 704 | IsOOBEComplete()).WillRepeatedly(Return(true)); |
| 705 | |
Jay Srinivasan | 480ddfa | 2012-06-01 19:15:26 -0700 | [diff] [blame] | 706 | string prefs_dir; |
| 707 | EXPECT_TRUE(utils::MakeTempDirectory("/tmp/ue_ut_prefs.XXXXXX", |
| 708 | &prefs_dir)); |
| 709 | ScopedDirRemover temp_dir_remover(prefs_dir); |
| 710 | |
| 711 | LOG_IF(ERROR, !prefs.Init(FilePath(prefs_dir))) |
| 712 | << "Failed to initialize preferences."; |
| 713 | EXPECT_TRUE(prefs.SetInt64(kPrefsUpdateCheckCount, initial_value)); |
| 714 | |
| 715 | int64 scatter_factor_in_seconds = 10; |
| 716 | |
| 717 | policy::MockDevicePolicy* device_policy = new policy::MockDevicePolicy(); |
| 718 | attempter_.policy_provider_.reset(new policy::PolicyProvider(device_policy)); |
| 719 | |
| 720 | EXPECT_CALL(*device_policy, LoadPolicy()).WillRepeatedly(Return(true)); |
Jay Srinivasan | 6f6ea00 | 2012-12-14 11:26:28 -0800 | [diff] [blame] | 721 | EXPECT_CALL(mock_system_state_, device_policy()).WillRepeatedly( |
Jay Srinivasan | 21be075 | 2012-07-25 15:44:56 -0700 | [diff] [blame] | 722 | Return(device_policy)); |
Jay Srinivasan | 480ddfa | 2012-06-01 19:15:26 -0700 | [diff] [blame] | 723 | |
| 724 | EXPECT_CALL(*device_policy, GetScatterFactorInSeconds(_)) |
| 725 | .WillRepeatedly(DoAll( |
| 726 | SetArgumentPointee<0>(scatter_factor_in_seconds), |
| 727 | Return(true))); |
| 728 | |
Gilad Arnold | b92f0df | 2013-01-10 16:32:45 -0800 | [diff] [blame] | 729 | attempter_.Update("", "", false, false, false); |
Jay Srinivasan | 480ddfa | 2012-06-01 19:15:26 -0700 | [diff] [blame] | 730 | EXPECT_EQ(scatter_factor_in_seconds, attempter_.scatter_factor_.InSeconds()); |
| 731 | |
| 732 | // Make sure the file still exists. |
| 733 | EXPECT_TRUE(prefs.Exists(kPrefsUpdateCheckCount)); |
| 734 | |
| 735 | int64 new_value; |
| 736 | EXPECT_TRUE(prefs.GetInt64(kPrefsUpdateCheckCount, &new_value)); |
| 737 | EXPECT_EQ(initial_value - 1, new_value); |
| 738 | |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 739 | EXPECT_TRUE( |
| 740 | attempter_.omaha_request_params_->update_check_count_wait_enabled()); |
Jay Srinivasan | 480ddfa | 2012-06-01 19:15:26 -0700 | [diff] [blame] | 741 | |
| 742 | // However, if the count is already 0, it's not decremented. Test that. |
| 743 | initial_value = 0; |
| 744 | EXPECT_TRUE(prefs.SetInt64(kPrefsUpdateCheckCount, initial_value)); |
Gilad Arnold | b92f0df | 2013-01-10 16:32:45 -0800 | [diff] [blame] | 745 | attempter_.Update("", "", false, false, false); |
Jay Srinivasan | 480ddfa | 2012-06-01 19:15:26 -0700 | [diff] [blame] | 746 | EXPECT_TRUE(prefs.Exists(kPrefsUpdateCheckCount)); |
| 747 | EXPECT_TRUE(prefs.GetInt64(kPrefsUpdateCheckCount, &new_value)); |
| 748 | EXPECT_EQ(initial_value, new_value); |
| 749 | |
| 750 | g_idle_add(&StaticQuitMainLoop, this); |
| 751 | } |
| 752 | |
Jay Srinivasan | 08fce04 | 2012-06-07 16:31:01 -0700 | [diff] [blame] | 753 | TEST_F(UpdateAttempterTest, NoScatteringDoneDuringManualUpdateTestStart) { |
| 754 | loop_ = g_main_loop_new(g_main_context_default(), FALSE); |
| 755 | g_idle_add(&StaticNoScatteringDoneDuringManualUpdateTestStart, this); |
| 756 | g_main_loop_run(loop_); |
| 757 | g_main_loop_unref(loop_); |
| 758 | loop_ = NULL; |
| 759 | } |
| 760 | |
| 761 | void UpdateAttempterTest::NoScatteringDoneDuringManualUpdateTestStart() { |
| 762 | // Tests that no scattering logic is enabled if the update check |
| 763 | // is manually done (as opposed to a scheduled update check) |
| 764 | int64 initial_value = 8; |
| 765 | Prefs prefs; |
| 766 | attempter_.prefs_ = &prefs; |
| 767 | |
| 768 | EXPECT_CALL(mock_system_state_, |
| 769 | IsOOBEComplete()).WillRepeatedly(Return(true)); |
| 770 | |
| 771 | string prefs_dir; |
| 772 | EXPECT_TRUE(utils::MakeTempDirectory("/tmp/ue_ut_prefs.XXXXXX", |
| 773 | &prefs_dir)); |
| 774 | ScopedDirRemover temp_dir_remover(prefs_dir); |
| 775 | |
| 776 | LOG_IF(ERROR, !prefs.Init(FilePath(prefs_dir))) |
| 777 | << "Failed to initialize preferences."; |
Jay Srinivasan | 21be075 | 2012-07-25 15:44:56 -0700 | [diff] [blame] | 778 | EXPECT_TRUE(prefs.SetInt64(kPrefsWallClockWaitPeriod, initial_value)); |
Jay Srinivasan | 08fce04 | 2012-06-07 16:31:01 -0700 | [diff] [blame] | 779 | EXPECT_TRUE(prefs.SetInt64(kPrefsUpdateCheckCount, initial_value)); |
| 780 | |
| 781 | // make sure scatter_factor is non-zero as scattering is disabled |
| 782 | // otherwise. |
| 783 | int64 scatter_factor_in_seconds = 50; |
| 784 | |
| 785 | policy::MockDevicePolicy* device_policy = new policy::MockDevicePolicy(); |
| 786 | attempter_.policy_provider_.reset(new policy::PolicyProvider(device_policy)); |
| 787 | |
| 788 | EXPECT_CALL(*device_policy, LoadPolicy()).WillRepeatedly(Return(true)); |
Jay Srinivasan | 6f6ea00 | 2012-12-14 11:26:28 -0800 | [diff] [blame] | 789 | EXPECT_CALL(mock_system_state_, device_policy()).WillRepeatedly( |
Jay Srinivasan | 21be075 | 2012-07-25 15:44:56 -0700 | [diff] [blame] | 790 | Return(device_policy)); |
Jay Srinivasan | 08fce04 | 2012-06-07 16:31:01 -0700 | [diff] [blame] | 791 | |
| 792 | EXPECT_CALL(*device_policy, GetScatterFactorInSeconds(_)) |
| 793 | .WillRepeatedly(DoAll( |
| 794 | SetArgumentPointee<0>(scatter_factor_in_seconds), |
| 795 | Return(true))); |
| 796 | |
Gilad Arnold | b92f0df | 2013-01-10 16:32:45 -0800 | [diff] [blame] | 797 | // Trigger an interactive check so we can test that scattering is disabled. |
| 798 | attempter_.Update("", "", false, true, false); |
Jay Srinivasan | 08fce04 | 2012-06-07 16:31:01 -0700 | [diff] [blame] | 799 | EXPECT_EQ(scatter_factor_in_seconds, attempter_.scatter_factor_.InSeconds()); |
| 800 | |
| 801 | // Make sure scattering is disabled for manual (i.e. user initiated) update |
Jay Srinivasan | 21be075 | 2012-07-25 15:44:56 -0700 | [diff] [blame] | 802 | // checks and all artifacts are removed. |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 803 | EXPECT_FALSE( |
| 804 | attempter_.omaha_request_params_->wall_clock_based_wait_enabled()); |
Jay Srinivasan | 08fce04 | 2012-06-07 16:31:01 -0700 | [diff] [blame] | 805 | EXPECT_FALSE(prefs.Exists(kPrefsWallClockWaitPeriod)); |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 806 | EXPECT_EQ(0, attempter_.omaha_request_params_->waiting_period().InSeconds()); |
| 807 | EXPECT_FALSE( |
| 808 | attempter_.omaha_request_params_->update_check_count_wait_enabled()); |
Jay Srinivasan | 08fce04 | 2012-06-07 16:31:01 -0700 | [diff] [blame] | 809 | EXPECT_FALSE(prefs.Exists(kPrefsUpdateCheckCount)); |
| 810 | |
| 811 | g_idle_add(&StaticQuitMainLoop, this); |
| 812 | } |
| 813 | |
Darin Petkov | f42cc1c | 2010-09-01 09:03:02 -0700 | [diff] [blame] | 814 | } // namespace chromeos_update_engine |