1 //
2 // Copyright (C) 2014 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_manager/real_system_provider.h"
18
19 #include <memory>
20
21 #include <base/time/time.h>
22 #include <gtest/gtest.h>
23
24 #include "update_engine/common/fake_boot_control.h"
25 #include "update_engine/common/fake_hardware.h"
26 #include "update_engine/update_manager/umtest_utils.h"
27
28 using std::unique_ptr;
29
30 namespace chromeos_update_manager {
31
32 class UmRealSystemProviderTest : public ::testing::Test {
33 protected:
SetUp()34 void SetUp() override {
35 provider_.reset(
36 new RealSystemProvider(&fake_hardware_, &fake_boot_control_));
37 EXPECT_TRUE(provider_->Init());
38 }
39
40 chromeos_update_engine::FakeHardware fake_hardware_;
41 chromeos_update_engine::FakeBootControl fake_boot_control_;
42 unique_ptr<RealSystemProvider> provider_;
43 };
44
TEST_F(UmRealSystemProviderTest,InitTest)45 TEST_F(UmRealSystemProviderTest, InitTest) {
46 EXPECT_NE(nullptr, provider_->var_is_normal_boot_mode());
47 EXPECT_NE(nullptr, provider_->var_is_official_build());
48 EXPECT_NE(nullptr, provider_->var_is_oobe_complete());
49 }
50
TEST_F(UmRealSystemProviderTest,IsOOBECompleteTrue)51 TEST_F(UmRealSystemProviderTest, IsOOBECompleteTrue) {
52 fake_hardware_.SetIsOOBEComplete(base::Time());
53 UmTestUtils::ExpectVariableHasValue(true, provider_->var_is_oobe_complete());
54 }
55
TEST_F(UmRealSystemProviderTest,IsOOBECompleteFalse)56 TEST_F(UmRealSystemProviderTest, IsOOBECompleteFalse) {
57 fake_hardware_.UnsetIsOOBEComplete();
58 UmTestUtils::ExpectVariableHasValue(false, provider_->var_is_oobe_complete());
59 }
60
61 } // namespace chromeos_update_manager
62