Update API: initial support
Initial pieces of the Update API callback framework.
- move the status callback params to a new object, UpdateEngineStatus to
allow for the easier addition of new params in the future.
- switch the IUpdateEngineStatusCallback to provide a
ParcelableUpdateEngineStatus instead of a series of individual params
- move the various GetStatus() methods to use the UpdateEngineStatus
object instead of a series of params (which will need future expansion)
- Add current and new product/os versions to both the UpdateEngineStatus
and the ParcelableUpdateEngineStatus.
Bug: 64808702
Test: unit tests, and performing OTAs via a test app calling
IUpdateEngine::AttemptUpdate() via UpdateManager::performUpdateNow()
Change-Id: I53f66f3511049f0809855814e1e758023cd8cc08
(cherry picked from commit 4f96ebf85022837603f2e10100a044d234b7d86f)
diff --git a/update_attempter_unittest.cc b/update_attempter_unittest.cc
index 911f664..dfeebcf 100644
--- a/update_attempter_unittest.cc
+++ b/update_attempter_unittest.cc
@@ -67,6 +67,7 @@
using std::string;
using std::unique_ptr;
using testing::DoAll;
+using testing::Field;
using testing::InSequence;
using testing::Ne;
using testing::NiceMock;
@@ -76,6 +77,7 @@
using testing::SaveArg;
using testing::SetArgumentPointee;
using testing::_;
+using update_engine::UpdateEngineStatus;
using update_engine::UpdateStatus;
namespace chromeos_update_engine {
@@ -137,7 +139,7 @@
EXPECT_EQ(0.0, attempter_.download_progress_);
EXPECT_EQ(0, attempter_.last_checked_time_);
EXPECT_EQ("0.0.0.0", attempter_.new_version_);
- EXPECT_EQ(0, attempter_.new_payload_size_);
+ EXPECT_EQ(0ULL, attempter_.new_payload_size_);
processor_ = new NiceMock<MockActionProcessor>();
attempter_.processor_.reset(processor_); // Transfers ownership.
prefs_ = fake_system_state_.mock_prefs();
@@ -253,11 +255,15 @@
attempter_.new_payload_size_ = bytes_total;
NiceMock<MockServiceObserver> observer;
EXPECT_CALL(observer,
- SendStatusUpdate(
- _, progress_1, UpdateStatus::DOWNLOADING, _, bytes_total));
+ SendStatusUpdate(AllOf(
+ Field(&UpdateEngineStatus::progress, progress_1),
+ Field(&UpdateEngineStatus::status, UpdateStatus::DOWNLOADING),
+ Field(&UpdateEngineStatus::new_size_bytes, bytes_total))));
EXPECT_CALL(observer,
- SendStatusUpdate(
- _, progress_2, UpdateStatus::DOWNLOADING, _, bytes_total));
+ SendStatusUpdate(AllOf(
+ Field(&UpdateEngineStatus::progress, progress_2),
+ Field(&UpdateEngineStatus::status, UpdateStatus::DOWNLOADING),
+ Field(&UpdateEngineStatus::new_size_bytes, bytes_total))));
attempter_.AddObserver(&observer);
attempter_.BytesReceived(bytes_progressed_1, bytes_received_1, bytes_total);
EXPECT_EQ(progress_1, attempter_.download_progress_);
@@ -280,9 +286,10 @@
attempter_.new_payload_size_ = bytes_total;
EXPECT_EQ(0.0, attempter_.download_progress_);
NiceMock<MockServiceObserver> observer;
- EXPECT_CALL(
- observer,
- SendStatusUpdate(_, _, UpdateStatus::DOWNLOADING, _, bytes_total));
+ EXPECT_CALL(observer,
+ SendStatusUpdate(AllOf(
+ Field(&UpdateEngineStatus::status, UpdateStatus::DOWNLOADING),
+ Field(&UpdateEngineStatus::new_size_bytes, bytes_total))));
attempter_.AddObserver(&observer);
attempter_.BytesReceived(bytes_progressed, bytes_received, bytes_total);
EXPECT_EQ(UpdateStatus::DOWNLOADING, attempter_.status_);
@@ -299,9 +306,11 @@
attempter_.new_payload_size_ = bytes_total;
EXPECT_EQ(0.0, attempter_.download_progress_);
NiceMock<MockServiceObserver> observer;
- EXPECT_CALL(
- observer,
- SendStatusUpdate(_, 1.0, UpdateStatus::DOWNLOADING, _, bytes_total));
+ EXPECT_CALL(observer,
+ SendStatusUpdate(AllOf(
+ Field(&UpdateEngineStatus::progress, 1.0),
+ Field(&UpdateEngineStatus::status, UpdateStatus::DOWNLOADING),
+ Field(&UpdateEngineStatus::new_size_bytes, bytes_total))));
attempter_.AddObserver(&observer);
attempter_.BytesReceived(bytes_progressed, bytes_received, bytes_total);
EXPECT_EQ(1.0, attempter_.download_progress_);