blob: a1d9480a9f22457e2a08ee7ab40896a654529e00 [file] [log] [blame]
Paul Stewartbe9abfd2013-04-22 12:18:48 -07001// 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 agrawalbebf1b82013-04-23 15:06:33 -070011#include "shill/mock_adaptors.h"
Paul Stewartbe9abfd2013-04-22 12:18:48 -070012#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 agrawalbebf1b82013-04-23 15:06:33 -070017#include "shill/service_property_change_test.h"
Paul Stewartbe9abfd2013-04-22 12:18:48 -070018#include "shill/technology.h"
19
20using testing::Return;
21
22namespace shill {
23
24class 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 agrawalbebf1b82013-04-23 15:06:33 -070036 ServiceMockAdaptor *GetAdaptor() {
37 return dynamic_cast<ServiceMockAdaptor *>(service_->adaptor());
38 }
39
Paul Stewartbe9abfd2013-04-22 12:18:48 -070040 MockControl control_;
41 MockEventDispatcher dispatcher_;
42 MockMetrics metrics_;
43 MockManager manager_;
44 MockEthernetEapProvider provider_;
45 scoped_refptr<EthernetEapService> service_;
46};
47
48TEST_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
56TEST_F(EthernetEapServiceTest, OnEapCredentialsChanged) {
57 EXPECT_CALL(manager_, ethernet_eap_provider()).WillOnce(Return(&provider_));
58 EXPECT_CALL(provider_, OnCredentialsChanged());
59 service_->OnEapCredentialsChanged();
60}
61
62TEST_F(EthernetEapServiceTest, OnEapCredentialPropertyChanged) {
63 EXPECT_CALL(manager_, ethernet_eap_provider()).WillOnce(Return(&provider_));
64 EXPECT_CALL(provider_, OnCredentialsChanged());
Ben Chan783f00b2013-09-20 13:50:34 -070065 service_->OnPropertyChanged(kEapPasswordProperty);
Paul Stewartbe9abfd2013-04-22 12:18:48 -070066}
67
68TEST_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 agrawalbebf1b82013-04-23 15:06:33 -070074TEST_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.
80TEST_F(EthernetEapServiceTest, CustomSetterNoopChange) {
81 TestCustomSetterNoopChange(service_, &manager_);
82}
83
Paul Stewartbe9abfd2013-04-22 12:18:48 -070084} // namespace shill