Paul Stewart | d408fdf | 2012-05-07 17:15:57 -0700 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
Darin Petkov | 98dd6a0 | 2011-06-10 15:12:57 -0700 | [diff] [blame] | 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" |
Chris Masone | 2b10554 | 2011-06-22 10:58:09 -0700 | [diff] [blame] | 6 | |
| 7 | #include "shill/dhcp_config.h" |
Chris Masone | 19e3040 | 2011-07-19 15:48:47 -0700 | [diff] [blame] | 8 | #include "shill/mock_control.h" |
Darin Petkov | 98dd6a0 | 2011-06-10 15:12:57 -0700 | [diff] [blame] | 9 | #include "shill/mock_glib.h" |
| 10 | |
| 11 | using testing::Test; |
| 12 | |
| 13 | namespace shill { |
| 14 | |
| 15 | namespace { |
| 16 | const char kDeviceName[] = "testdevicename"; |
Paul Stewart | d32f484 | 2012-01-11 16:08:13 -0800 | [diff] [blame] | 17 | const char kHostName[] = "testhostname"; |
Paul Stewart | d408fdf | 2012-05-07 17:15:57 -0700 | [diff] [blame] | 18 | const char kStorageIdentifier[] = "teststorageidentifier"; |
| 19 | const bool kArpGateway = false; |
Darin Petkov | 98dd6a0 | 2011-06-10 15:12:57 -0700 | [diff] [blame] | 20 | } // namespace {} |
| 21 | |
| 22 | class DHCPProviderTest : public Test { |
| 23 | public: |
Darin Petkov | f65e928 | 2011-06-21 14:29:56 -0700 | [diff] [blame] | 24 | DHCPProviderTest() : provider_(DHCPProvider::GetInstance()) { |
Darin Petkov | 98dd6a0 | 2011-06-10 15:12:57 -0700 | [diff] [blame] | 25 | provider_->glib_ = &glib_; |
Chris Masone | 19e3040 | 2011-07-19 15:48:47 -0700 | [diff] [blame] | 26 | provider_->control_interface_ = &control_; |
Darin Petkov | 98dd6a0 | 2011-06-10 15:12:57 -0700 | [diff] [blame] | 27 | } |
| 28 | |
| 29 | protected: |
Chris Masone | 19e3040 | 2011-07-19 15:48:47 -0700 | [diff] [blame] | 30 | MockControl control_; |
Darin Petkov | 98dd6a0 | 2011-06-10 15:12:57 -0700 | [diff] [blame] | 31 | MockGLib glib_; |
Darin Petkov | 98dd6a0 | 2011-06-10 15:12:57 -0700 | [diff] [blame] | 32 | DHCPProvider *provider_; |
| 33 | }; |
| 34 | |
| 35 | TEST_F(DHCPProviderTest, CreateConfig) { |
Paul Stewart | d408fdf | 2012-05-07 17:15:57 -0700 | [diff] [blame] | 36 | DHCPConfigRefPtr config = provider_->CreateConfig(kDeviceName, |
| 37 | kHostName, |
| 38 | kStorageIdentifier, |
| 39 | kArpGateway); |
Darin Petkov | 98dd6a0 | 2011-06-10 15:12:57 -0700 | [diff] [blame] | 40 | EXPECT_TRUE(config.get()); |
| 41 | EXPECT_EQ(&glib_, config->glib_); |
Darin Petkov | f65e928 | 2011-06-21 14:29:56 -0700 | [diff] [blame] | 42 | EXPECT_EQ(kDeviceName, config->device_name()); |
Darin Petkov | 98dd6a0 | 2011-06-10 15:12:57 -0700 | [diff] [blame] | 43 | EXPECT_TRUE(provider_->configs_.empty()); |
| 44 | } |
| 45 | |
| 46 | } // namespace shill |