summaryrefslogtreecommitdiffstats
path: root/parcelable_update_engine_status_unittest.cc
diff options
context:
space:
mode:
authorAaron Wood <aaronwood@google.com>2017-08-28 14:51:21 -0700
committerSen Jiang <senj@google.com>2017-09-19 18:08:34 -0700
commit7f92e2b7060cb35719acf96ef96a4e273e165bc5 (patch)
tree5d3c045386b04d8ed96cba1041a9e105713ef2c8 /parcelable_update_engine_status_unittest.cc
parentb1e063a383115ae2bbc62cbd64047c913724921c (diff)
downloadandroid_system_update_engine-7f92e2b7060cb35719acf96ef96a4e273e165bc5.tar.gz
android_system_update_engine-7f92e2b7060cb35719acf96ef96a4e273e165bc5.tar.bz2
android_system_update_engine-7f92e2b7060cb35719acf96ef96a4e273e165bc5.zip
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)
Diffstat (limited to 'parcelable_update_engine_status_unittest.cc')
-rw-r--r--parcelable_update_engine_status_unittest.cc93
1 files changed, 93 insertions, 0 deletions
diff --git a/parcelable_update_engine_status_unittest.cc b/parcelable_update_engine_status_unittest.cc
new file mode 100644
index 00000000..3e6f7eb3
--- /dev/null
+++ b/parcelable_update_engine_status_unittest.cc
@@ -0,0 +1,93 @@
+//
+// Copyright (C) 2017 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include "update_engine/parcelable_update_engine_status.h"
+#include "update_engine/update_status_utils.h"
+
+#include <binder/Parcel.h>
+#include <gtest/gtest.h>
+
+using android::Parcel;
+using android::String16;
+using android::brillo::ParcelableUpdateEngineStatus;
+using android::status_t;
+using update_engine::UpdateEngineStatus;
+using update_engine::UpdateStatus;
+
+TEST(ParcelableUpdateEngineStatusTest, TestCreationFromUpdateEngineStatus) {
+ // This test creates an object and verifies that all the UpdateEngineStatus
+ // values are properly reflected in the Parcelable version of the class.
+
+ UpdateEngineStatus ue_status = {123456789,
+ UpdateStatus::DOWNLOADING,
+ "0.1.2.3",
+ "1.2.3.4",
+ 0.5f,
+ 34567,
+ "2.3.4.5",
+ "3.4.5.6"};
+ ParcelableUpdateEngineStatus parcelable_status(ue_status);
+ EXPECT_EQ(ue_status.last_checked_time_ms,
+ parcelable_status.last_checked_time_);
+ EXPECT_EQ(
+ String16{chromeos_update_engine::UpdateStatusToString(ue_status.status)},
+ parcelable_status.current_operation_);
+ EXPECT_EQ(String16{ue_status.current_version.c_str()},
+ parcelable_status.current_version_);
+ EXPECT_EQ(String16{ue_status.current_system_version.c_str()},
+ parcelable_status.current_system_version_);
+ EXPECT_EQ(ue_status.progress, parcelable_status.progress_);
+ EXPECT_EQ(static_cast<int64_t>(ue_status.new_size_bytes),
+ parcelable_status.new_size_);
+ EXPECT_EQ(String16{ue_status.new_version.c_str()},
+ parcelable_status.new_version_);
+ EXPECT_EQ(String16{ue_status.new_system_version.c_str()},
+ parcelable_status.new_system_version_);
+}
+
+TEST(ParcelableUpdateEngineStatusTest, TestParceling) {
+ // This tests the writeToParcel and readFromParcel methods for being correctly
+ // matched.
+ UpdateEngineStatus ue_status = {123456789,
+ UpdateStatus::DOWNLOADING,
+ "0.1.2.3",
+ "1.2.3.4",
+ 0.5f,
+ 34567,
+ "2.3.4.5",
+ "3.4.5.6"};
+ ParcelableUpdateEngineStatus source_status(ue_status);
+ Parcel parcel_source, parcel_target;
+ status_t status = source_status.writeToParcel(&parcel_source);
+ EXPECT_EQ(::android::OK, status);
+ size_t parcel_len = parcel_source.dataSize();
+ status = parcel_target.setData(parcel_source.data(), parcel_len);
+ EXPECT_EQ(::android::OK, status);
+ ParcelableUpdateEngineStatus target_status;
+ status = target_status.readFromParcel(&parcel_target);
+ EXPECT_EQ(::android::OK, status);
+
+ EXPECT_EQ(source_status.last_checked_time_, target_status.last_checked_time_);
+ EXPECT_EQ(source_status.current_operation_, target_status.current_operation_);
+ EXPECT_EQ(source_status.current_version_, target_status.current_version_);
+ EXPECT_EQ(source_status.current_system_version_,
+ target_status.current_system_version_);
+ EXPECT_EQ(source_status.progress_, target_status.progress_);
+ EXPECT_EQ(source_status.new_size_, target_status.new_size_);
+ EXPECT_EQ(source_status.new_version_, target_status.new_version_);
+ EXPECT_EQ(source_status.new_system_version_,
+ target_status.new_system_version_);
+}