blob: 48491d54fdd6affc81013f522bcdc6d274c5d9d5 [file] [log] [blame]
Alex Deymo2de23f52014-02-26 14:30:13 -08001// Copyright (c) 2014 The Chromium OS Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include <gtest/gtest.h>
6
Gilad Arnold5ef9c482014-03-03 13:51:02 -08007#include "update_engine/fake_clock.h"
8#include "update_engine/mock_dbus_wrapper.h"
Alex Deymo2de23f52014-02-26 14:30:13 -08009#include "update_engine/policy_manager/real_state.h"
10#include "update_engine/policy_manager/pmtest_utils.h"
11
Gilad Arnold5ef9c482014-03-03 13:51:02 -080012using chromeos_update_engine::FakeClock;
13using chromeos_update_engine::MockDBusWrapper;
14using testing::_;
15using testing::NiceMock;
16using testing::Return;
17
18namespace {
19
20DBusGConnection* const kFakeConnection = reinterpret_cast<DBusGConnection*>(1);
21
22} // namespace
23
Alex Deymo2de23f52014-02-26 14:30:13 -080024namespace chromeos_policy_manager {
25
26TEST(PmRealStateTest, InitTest) {
Gilad Arnold5ef9c482014-03-03 13:51:02 -080027 NiceMock<MockDBusWrapper> mock_dbus;
28 FakeClock fake_clock;
29 EXPECT_CALL(mock_dbus, BusGet(_, _)).WillOnce(Return(kFakeConnection));
30 RealState state(&mock_dbus, &fake_clock);
Alex Deymo2de23f52014-02-26 14:30:13 -080031 EXPECT_TRUE(state.Init());
32 // Check that the providers are being initialized.
33 PMTEST_ASSERT_NOT_NULL(state.random_provider());
Alex Deymo540d9422014-02-27 11:17:31 -080034 PMTEST_EXPECT_NOT_NULL(state.random_provider()->var_seed());
Alex Deymo2de23f52014-02-26 14:30:13 -080035}
36
37} // namespace chromeos_policy_manager