blob: 042cea5bf4bc2525989f970036e4d0c00a45eea4 [file] [log] [blame]
Paul Stewartd408fdf2012-05-07 17:15:57 -07001// Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
Darin Petkov98dd6a02011-06-10 15:12:57 -07002// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "shill/dhcp_provider.h"
Chris Masone2b105542011-06-22 10:58:09 -07006
7#include "shill/dhcp_config.h"
Chris Masone19e30402011-07-19 15:48:47 -07008#include "shill/mock_control.h"
Darin Petkov98dd6a02011-06-10 15:12:57 -07009#include "shill/mock_glib.h"
10
11using testing::Test;
12
13namespace shill {
14
15namespace {
16const char kDeviceName[] = "testdevicename";
Paul Stewartd32f4842012-01-11 16:08:13 -080017const char kHostName[] = "testhostname";
Paul Stewartd408fdf2012-05-07 17:15:57 -070018const char kStorageIdentifier[] = "teststorageidentifier";
19const bool kArpGateway = false;
Darin Petkov98dd6a02011-06-10 15:12:57 -070020} // namespace {}
21
22class DHCPProviderTest : public Test {
23 public:
Darin Petkovf65e9282011-06-21 14:29:56 -070024 DHCPProviderTest() : provider_(DHCPProvider::GetInstance()) {
Darin Petkov98dd6a02011-06-10 15:12:57 -070025 provider_->glib_ = &glib_;
Chris Masone19e30402011-07-19 15:48:47 -070026 provider_->control_interface_ = &control_;
Darin Petkov98dd6a02011-06-10 15:12:57 -070027 }
28
29 protected:
Chris Masone19e30402011-07-19 15:48:47 -070030 MockControl control_;
Darin Petkov98dd6a02011-06-10 15:12:57 -070031 MockGLib glib_;
Darin Petkov98dd6a02011-06-10 15:12:57 -070032 DHCPProvider *provider_;
33};
34
35TEST_F(DHCPProviderTest, CreateConfig) {
Paul Stewartd408fdf2012-05-07 17:15:57 -070036 DHCPConfigRefPtr config = provider_->CreateConfig(kDeviceName,
37 kHostName,
38 kStorageIdentifier,
39 kArpGateway);
Darin Petkov98dd6a02011-06-10 15:12:57 -070040 EXPECT_TRUE(config.get());
41 EXPECT_EQ(&glib_, config->glib_);
Darin Petkovf65e9282011-06-21 14:29:56 -070042 EXPECT_EQ(kDeviceName, config->device_name());
Darin Petkov98dd6a02011-06-10 15:12:57 -070043 EXPECT_TRUE(provider_->configs_.empty());
44}
45
46} // namespace shill