blob: dbd80d7a629a613735f6529a12358c399ef34a35 [file] [log] [blame]
Jae Hoon Kim916af852019-08-01 17:45:30 -07001//
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
23using std::string;
24
25namespace chromeos_update_engine {
26
27TEST(UpdateStatusUtilsTest, UpdateEngineStatusToStringDefaultTest) {
28 string print =
29 R"(CURRENT_OP=UPDATE_STATUS_IDLE
30IS_INSTALL=false
31LAST_CHECKED_TIME=0
32NEW_SIZE=0
33NEW_VERSION=
34PROGRESS=0.0
35)";
36 EXPECT_EQ(print, UpdateEngineStatusToString({}));
37}
38
39TEST(UpdateStatusUtilsTest, UpdateEngineStatusToStringTest) {
40 update_engine::UpdateEngineStatus update_engine_status = {
41 .status = update_engine::UpdateStatus::CHECKING_FOR_UPDATE,
42 .is_install = true,
43 .last_checked_time = 156000000,
44 .new_size_bytes = 888,
45 .new_version = "12345.0.0",
46 .progress = 0.5,
47 };
48 string print =
49 R"(CURRENT_OP=UPDATE_STATUS_CHECKING_FOR_UPDATE
50IS_INSTALL=true
51LAST_CHECKED_TIME=156000000
52NEW_SIZE=888
53NEW_VERSION=12345.0.0
54PROGRESS=0.5
55)";
56 EXPECT_EQ(print, UpdateEngineStatusToString(update_engine_status));
57}
58
59} // namespace chromeos_update_engine