Darin Petkov | 98dd6a0 | 2011-06-10 15:12:57 -0700 | [diff] [blame^] | 1 | // Copyright (c) 2011 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 "shill/dhcp_provider.h" |
| 6 | #include "shill/mock_control.h" |
| 7 | #include "shill/mock_device.h" |
| 8 | #include "shill/mock_glib.h" |
| 9 | |
| 10 | using testing::Test; |
| 11 | |
| 12 | namespace shill { |
| 13 | |
| 14 | namespace { |
| 15 | const char kDeviceName[] = "testdevicename"; |
| 16 | } // namespace {} |
| 17 | |
| 18 | class DHCPProviderTest : public Test { |
| 19 | public: |
| 20 | DHCPProviderTest() |
| 21 | : device_(new MockDevice(&control_interface_, |
| 22 | NULL, |
| 23 | NULL, |
| 24 | kDeviceName, |
| 25 | 0)), |
| 26 | provider_(DHCPProvider::GetInstance()) { |
| 27 | provider_->glib_ = &glib_; |
| 28 | } |
| 29 | |
| 30 | protected: |
| 31 | MockGLib glib_; |
| 32 | MockControl control_interface_; |
| 33 | scoped_refptr<MockDevice> device_; |
| 34 | DHCPProvider *provider_; |
| 35 | }; |
| 36 | |
| 37 | TEST_F(DHCPProviderTest, CreateConfig) { |
| 38 | DHCPConfigRefPtr config = provider_->CreateConfig(device_); |
| 39 | EXPECT_TRUE(config.get()); |
| 40 | EXPECT_EQ(&glib_, config->glib_); |
| 41 | EXPECT_EQ(kDeviceName, config->GetDeviceName()); |
| 42 | EXPECT_TRUE(provider_->configs_.empty()); |
| 43 | } |
| 44 | |
| 45 | } // namespace shill |