| Jae Hoon Kim | 916af85 | 2019-08-01 17:45:30 -0700 | [diff] [blame] | 1 | // | 
|  | 2 | // Copyright (C) 2019 The Android Open Source Project | 
|  | 3 | // | 
|  | 4 | // Licensed under the Apache License, Version 2.0 (the "License"); | 
|  | 5 | // you may not use this file except in compliance with the License. | 
|  | 6 | // You may obtain a copy of the License at | 
|  | 7 | // | 
|  | 8 | //      http://www.apache.org/licenses/LICENSE-2.0 | 
|  | 9 | // | 
|  | 10 | // Unless required by applicable law or agreed to in writing, software | 
|  | 11 | // distributed under the License is distributed on an "AS IS" BASIS, | 
|  | 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
|  | 13 | // See the License for the specific language governing permissions and | 
|  | 14 | // limitations under the License. | 
|  | 15 | // | 
|  | 16 |  | 
|  | 17 | #include "update_engine/update_status_utils.h" | 
|  | 18 |  | 
|  | 19 | #include <string> | 
|  | 20 |  | 
|  | 21 | #include <gtest/gtest.h> | 
|  | 22 |  | 
|  | 23 | using std::string; | 
|  | 24 |  | 
|  | 25 | namespace chromeos_update_engine { | 
|  | 26 |  | 
| Jae Hoon Kim | 916af85 | 2019-08-01 17:45:30 -0700 | [diff] [blame] | 27 | TEST(UpdateStatusUtilsTest, UpdateEngineStatusToStringTest) { | 
| Caroline Tice | f407f18 | 2019-09-23 10:32:09 -0700 | [diff] [blame] | 28 | // Keep field assignments in same order as they were declared, | 
|  | 29 | // to prevent compiler warning, -Wreorder-init-fields. | 
| Jae Hoon Kim | 916af85 | 2019-08-01 17:45:30 -0700 | [diff] [blame] | 30 | update_engine::UpdateEngineStatus update_engine_status = { | 
| Jae Hoon Kim | 916af85 | 2019-08-01 17:45:30 -0700 | [diff] [blame] | 31 | .last_checked_time = 156000000, | 
| Caroline Tice | f407f18 | 2019-09-23 10:32:09 -0700 | [diff] [blame] | 32 | .status = update_engine::UpdateStatus::CHECKING_FOR_UPDATE, | 
|  | 33 | .progress = 0.5, | 
| Jae Hoon Kim | 916af85 | 2019-08-01 17:45:30 -0700 | [diff] [blame] | 34 | .new_size_bytes = 888, | 
|  | 35 | .new_version = "12345.0.0", | 
| Caroline Tice | f407f18 | 2019-09-23 10:32:09 -0700 | [diff] [blame] | 36 | .is_enterprise_rollback = true, | 
|  | 37 | .is_install = true, | 
| Miriam Polzer | 0cf1acb | 2020-04-29 17:39:51 +0200 | [diff] [blame] | 38 | .will_powerwash_after_reboot = true, | 
| Jae Hoon Kim | 916af85 | 2019-08-01 17:45:30 -0700 | [diff] [blame] | 39 | }; | 
|  | 40 | string print = | 
|  | 41 | R"(CURRENT_OP=UPDATE_STATUS_CHECKING_FOR_UPDATE | 
| Amin Hassani | 9be122e | 2019-08-29 09:20:12 -0700 | [diff] [blame] | 42 | IS_ENTERPRISE_ROLLBACK=true | 
| Jae Hoon Kim | 916af85 | 2019-08-01 17:45:30 -0700 | [diff] [blame] | 43 | IS_INSTALL=true | 
|  | 44 | LAST_CHECKED_TIME=156000000 | 
|  | 45 | NEW_SIZE=888 | 
|  | 46 | NEW_VERSION=12345.0.0 | 
|  | 47 | PROGRESS=0.5 | 
| Miriam Polzer | 0cf1acb | 2020-04-29 17:39:51 +0200 | [diff] [blame] | 48 | WILL_POWERWASH_AFTER_REBOOT=true | 
| Jae Hoon Kim | 916af85 | 2019-08-01 17:45:30 -0700 | [diff] [blame] | 49 | )"; | 
|  | 50 | EXPECT_EQ(print, UpdateEngineStatusToString(update_engine_status)); | 
|  | 51 | } | 
|  | 52 |  | 
|  | 53 | }  // namespace chromeos_update_engine |