Paul Stewart | be9abfd | 2013-04-22 12:18:48 -0700 | [diff] [blame] | 1 | // Copyright (c) 2013 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/ethernet_eap_service.h" |
| 6 | |
| 7 | #include <base/bind.h> |
| 8 | #include <chromeos/dbus/service_constants.h> |
| 9 | #include <gtest/gtest.h> |
| 10 | |
mukesh agrawal | bebf1b8 | 2013-04-23 15:06:33 -0700 | [diff] [blame] | 11 | #include "shill/mock_adaptors.h" |
Paul Stewart | be9abfd | 2013-04-22 12:18:48 -0700 | [diff] [blame] | 12 | #include "shill/mock_control.h" |
| 13 | #include "shill/mock_ethernet_eap_provider.h" |
| 14 | #include "shill/mock_event_dispatcher.h" |
| 15 | #include "shill/mock_manager.h" |
| 16 | #include "shill/mock_metrics.h" |
mukesh agrawal | bebf1b8 | 2013-04-23 15:06:33 -0700 | [diff] [blame] | 17 | #include "shill/service_property_change_test.h" |
Paul Stewart | be9abfd | 2013-04-22 12:18:48 -0700 | [diff] [blame] | 18 | #include "shill/technology.h" |
| 19 | |
| 20 | using testing::Return; |
| 21 | |
| 22 | namespace shill { |
| 23 | |
| 24 | class EthernetEapServiceTest : public testing::Test { |
| 25 | public: |
| 26 | EthernetEapServiceTest() |
| 27 | : metrics_(&dispatcher_), |
| 28 | manager_(&control_, &dispatcher_, &metrics_, NULL), |
| 29 | service_(new EthernetEapService(&control_, |
| 30 | &dispatcher_, |
| 31 | &metrics_, |
| 32 | &manager_)) {} |
| 33 | virtual ~EthernetEapServiceTest() {} |
| 34 | |
| 35 | protected: |
mukesh agrawal | bebf1b8 | 2013-04-23 15:06:33 -0700 | [diff] [blame] | 36 | ServiceMockAdaptor *GetAdaptor() { |
| 37 | return dynamic_cast<ServiceMockAdaptor *>(service_->adaptor()); |
| 38 | } |
| 39 | |
Paul Stewart | be9abfd | 2013-04-22 12:18:48 -0700 | [diff] [blame] | 40 | MockControl control_; |
| 41 | MockEventDispatcher dispatcher_; |
| 42 | MockMetrics metrics_; |
| 43 | MockManager manager_; |
| 44 | MockEthernetEapProvider provider_; |
| 45 | scoped_refptr<EthernetEapService> service_; |
| 46 | }; |
| 47 | |
| 48 | TEST_F(EthernetEapServiceTest, MethodOverrides) { |
| 49 | EXPECT_EQ("/", service_->GetDeviceRpcId(NULL)); |
| 50 | EXPECT_EQ("etherneteap_all", service_->GetStorageIdentifier()); |
| 51 | EXPECT_EQ(Technology::kEthernetEap, service_->technology()); |
| 52 | EXPECT_TRUE(service_->Is8021x()); |
| 53 | EXPECT_FALSE(service_->IsVisible()); |
| 54 | } |
| 55 | |
| 56 | TEST_F(EthernetEapServiceTest, OnEapCredentialsChanged) { |
| 57 | EXPECT_CALL(manager_, ethernet_eap_provider()).WillOnce(Return(&provider_)); |
| 58 | EXPECT_CALL(provider_, OnCredentialsChanged()); |
| 59 | service_->OnEapCredentialsChanged(); |
| 60 | } |
| 61 | |
| 62 | TEST_F(EthernetEapServiceTest, OnEapCredentialPropertyChanged) { |
| 63 | EXPECT_CALL(manager_, ethernet_eap_provider()).WillOnce(Return(&provider_)); |
| 64 | EXPECT_CALL(provider_, OnCredentialsChanged()); |
Ben Chan | 783f00b | 2013-09-20 13:50:34 -0700 | [diff] [blame] | 65 | service_->OnPropertyChanged(kEapPasswordProperty); |
Paul Stewart | be9abfd | 2013-04-22 12:18:48 -0700 | [diff] [blame] | 66 | } |
| 67 | |
| 68 | TEST_F(EthernetEapServiceTest, Unload) { |
| 69 | EXPECT_CALL(manager_, ethernet_eap_provider()).WillOnce(Return(&provider_)); |
| 70 | EXPECT_CALL(provider_, OnCredentialsChanged()); |
| 71 | EXPECT_FALSE(service_->Unload()); |
| 72 | } |
| 73 | |
mukesh agrawal | bebf1b8 | 2013-04-23 15:06:33 -0700 | [diff] [blame] | 74 | TEST_F(EthernetEapServiceTest, PropertyChanges) { |
| 75 | TestCommonPropertyChanges(service_, GetAdaptor()); |
| 76 | } |
| 77 | |
| 78 | // Custom property setters should return false, and make no changes, if |
| 79 | // the new value is the same as the old value. |
| 80 | TEST_F(EthernetEapServiceTest, CustomSetterNoopChange) { |
| 81 | TestCustomSetterNoopChange(service_, &manager_); |
| 82 | } |
| 83 | |
Paul Stewart | be9abfd | 2013-04-22 12:18:48 -0700 | [diff] [blame] | 84 | } // namespace shill |