OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chromeos/network/shill_property_handler.h" | 5 #include "chromeos/network/shill_property_handler.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 23 matching lines...) Expand all Loading... |
34 LOG(ERROR) << "Shill Error: " << error_name << " : " << error_message; | 34 LOG(ERROR) << "Shill Error: " << error_name << " : " << error_message; |
35 } | 35 } |
36 | 36 |
37 class TestListener : public internal::ShillPropertyHandler::Listener { | 37 class TestListener : public internal::ShillPropertyHandler::Listener { |
38 public: | 38 public: |
39 TestListener() : technology_list_updates_(0), | 39 TestListener() : technology_list_updates_(0), |
40 errors_(0) { | 40 errors_(0) { |
41 } | 41 } |
42 | 42 |
43 virtual void UpdateManagedList(ManagedState::ManagedType type, | 43 virtual void UpdateManagedList(ManagedState::ManagedType type, |
44 const base::ListValue& entries) OVERRIDE { | 44 const base::ListValue& entries) override { |
45 VLOG(1) << "UpdateManagedList[" << ManagedState::TypeToString(type) << "]: " | 45 VLOG(1) << "UpdateManagedList[" << ManagedState::TypeToString(type) << "]: " |
46 << entries.GetSize(); | 46 << entries.GetSize(); |
47 UpdateEntries(GetTypeString(type), entries); | 47 UpdateEntries(GetTypeString(type), entries); |
48 } | 48 } |
49 | 49 |
50 virtual void UpdateManagedStateProperties( | 50 virtual void UpdateManagedStateProperties( |
51 ManagedState::ManagedType type, | 51 ManagedState::ManagedType type, |
52 const std::string& path, | 52 const std::string& path, |
53 const base::DictionaryValue& properties) OVERRIDE { | 53 const base::DictionaryValue& properties) override { |
54 VLOG(2) << "UpdateManagedStateProperties: " << GetTypeString(type); | 54 VLOG(2) << "UpdateManagedStateProperties: " << GetTypeString(type); |
55 initial_property_updates(GetTypeString(type))[path] += 1; | 55 initial_property_updates(GetTypeString(type))[path] += 1; |
56 } | 56 } |
57 | 57 |
58 virtual void ProfileListChanged() OVERRIDE { | 58 virtual void ProfileListChanged() override { |
59 } | 59 } |
60 | 60 |
61 virtual void UpdateNetworkServiceProperty( | 61 virtual void UpdateNetworkServiceProperty( |
62 const std::string& service_path, | 62 const std::string& service_path, |
63 const std::string& key, | 63 const std::string& key, |
64 const base::Value& value) OVERRIDE { | 64 const base::Value& value) override { |
65 AddPropertyUpdate(shill::kServiceCompleteListProperty, service_path); | 65 AddPropertyUpdate(shill::kServiceCompleteListProperty, service_path); |
66 } | 66 } |
67 | 67 |
68 virtual void UpdateDeviceProperty( | 68 virtual void UpdateDeviceProperty( |
69 const std::string& device_path, | 69 const std::string& device_path, |
70 const std::string& key, | 70 const std::string& key, |
71 const base::Value& value) OVERRIDE { | 71 const base::Value& value) override { |
72 AddPropertyUpdate(shill::kDevicesProperty, device_path); | 72 AddPropertyUpdate(shill::kDevicesProperty, device_path); |
73 } | 73 } |
74 | 74 |
75 virtual void UpdateIPConfigProperties( | 75 virtual void UpdateIPConfigProperties( |
76 ManagedState::ManagedType type, | 76 ManagedState::ManagedType type, |
77 const std::string& path, | 77 const std::string& path, |
78 const std::string& ip_config_path, | 78 const std::string& ip_config_path, |
79 const base::DictionaryValue& properties) OVERRIDE { | 79 const base::DictionaryValue& properties) override { |
80 AddPropertyUpdate(shill::kIPConfigsProperty, ip_config_path); | 80 AddPropertyUpdate(shill::kIPConfigsProperty, ip_config_path); |
81 } | 81 } |
82 | 82 |
83 virtual void TechnologyListChanged() OVERRIDE { | 83 virtual void TechnologyListChanged() override { |
84 VLOG(1) << "TechnologyListChanged."; | 84 VLOG(1) << "TechnologyListChanged."; |
85 ++technology_list_updates_; | 85 ++technology_list_updates_; |
86 } | 86 } |
87 | 87 |
88 virtual void CheckPortalListChanged( | 88 virtual void CheckPortalListChanged( |
89 const std::string& check_portal_list) OVERRIDE { | 89 const std::string& check_portal_list) override { |
90 } | 90 } |
91 | 91 |
92 virtual void ManagedStateListChanged( | 92 virtual void ManagedStateListChanged( |
93 ManagedState::ManagedType type) OVERRIDE { | 93 ManagedState::ManagedType type) override { |
94 VLOG(1) << "ManagedStateListChanged: " << GetTypeString(type); | 94 VLOG(1) << "ManagedStateListChanged: " << GetTypeString(type); |
95 AddStateListUpdate(GetTypeString(type)); | 95 AddStateListUpdate(GetTypeString(type)); |
96 } | 96 } |
97 | 97 |
98 virtual void DefaultNetworkServiceChanged( | 98 virtual void DefaultNetworkServiceChanged( |
99 const std::string& service_path) OVERRIDE { | 99 const std::string& service_path) override { |
100 } | 100 } |
101 | 101 |
102 std::vector<std::string>& entries(const std::string& type) { | 102 std::vector<std::string>& entries(const std::string& type) { |
103 return entries_[type]; | 103 return entries_[type]; |
104 } | 104 } |
105 std::map<std::string, int>& property_updates(const std::string& type) { | 105 std::map<std::string, int>& property_updates(const std::string& type) { |
106 return property_updates_[type]; | 106 return property_updates_[type]; |
107 } | 107 } |
108 std::map<std::string, int>& initial_property_updates( | 108 std::map<std::string, int>& initial_property_updates( |
109 const std::string& type) { | 109 const std::string& type) { |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 public: | 168 public: |
169 ShillPropertyHandlerTest() | 169 ShillPropertyHandlerTest() |
170 : manager_test_(NULL), | 170 : manager_test_(NULL), |
171 device_test_(NULL), | 171 device_test_(NULL), |
172 service_test_(NULL), | 172 service_test_(NULL), |
173 profile_test_(NULL) { | 173 profile_test_(NULL) { |
174 } | 174 } |
175 virtual ~ShillPropertyHandlerTest() { | 175 virtual ~ShillPropertyHandlerTest() { |
176 } | 176 } |
177 | 177 |
178 virtual void SetUp() OVERRIDE { | 178 virtual void SetUp() override { |
179 // Initialize DBusThreadManager with a stub implementation. | 179 // Initialize DBusThreadManager with a stub implementation. |
180 DBusThreadManager::Initialize(); | 180 DBusThreadManager::Initialize(); |
181 // Get the test interface for manager / device / service and clear the | 181 // Get the test interface for manager / device / service and clear the |
182 // default stub properties. | 182 // default stub properties. |
183 manager_test_ = | 183 manager_test_ = |
184 DBusThreadManager::Get()->GetShillManagerClient()->GetTestInterface(); | 184 DBusThreadManager::Get()->GetShillManagerClient()->GetTestInterface(); |
185 ASSERT_TRUE(manager_test_); | 185 ASSERT_TRUE(manager_test_); |
186 device_test_ = | 186 device_test_ = |
187 DBusThreadManager::Get()->GetShillDeviceClient()->GetTestInterface(); | 187 DBusThreadManager::Get()->GetShillDeviceClient()->GetTestInterface(); |
188 ASSERT_TRUE(device_test_); | 188 ASSERT_TRUE(device_test_); |
189 service_test_ = | 189 service_test_ = |
190 DBusThreadManager::Get()->GetShillServiceClient()->GetTestInterface(); | 190 DBusThreadManager::Get()->GetShillServiceClient()->GetTestInterface(); |
191 ASSERT_TRUE(service_test_); | 191 ASSERT_TRUE(service_test_); |
192 profile_test_ = | 192 profile_test_ = |
193 DBusThreadManager::Get()->GetShillProfileClient()->GetTestInterface(); | 193 DBusThreadManager::Get()->GetShillProfileClient()->GetTestInterface(); |
194 ASSERT_TRUE(profile_test_); | 194 ASSERT_TRUE(profile_test_); |
195 SetupShillPropertyHandler(); | 195 SetupShillPropertyHandler(); |
196 message_loop_.RunUntilIdle(); | 196 message_loop_.RunUntilIdle(); |
197 } | 197 } |
198 | 198 |
199 virtual void TearDown() OVERRIDE { | 199 virtual void TearDown() override { |
200 shill_property_handler_.reset(); | 200 shill_property_handler_.reset(); |
201 listener_.reset(); | 201 listener_.reset(); |
202 DBusThreadManager::Shutdown(); | 202 DBusThreadManager::Shutdown(); |
203 } | 203 } |
204 | 204 |
205 void AddDevice(const std::string& type, const std::string& id) { | 205 void AddDevice(const std::string& type, const std::string& id) { |
206 ASSERT_TRUE(IsValidType(type)); | 206 ASSERT_TRUE(IsValidType(type)); |
207 device_test_->AddDevice(id, type, id); | 207 device_test_->AddDevice(id, type, id); |
208 } | 208 } |
209 | 209 |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 shill_property_handler_->UpdateManagerProperties(); | 504 shill_property_handler_->UpdateManagerProperties(); |
505 message_loop_.RunUntilIdle(); | 505 message_loop_.RunUntilIdle(); |
506 EXPECT_EQ(1, listener_->list_updates(shill::kServiceCompleteListProperty)); | 506 EXPECT_EQ(1, listener_->list_updates(shill::kServiceCompleteListProperty)); |
507 EXPECT_EQ(1, listener_->initial_property_updates( | 507 EXPECT_EQ(1, listener_->initial_property_updates( |
508 shill::kServiceCompleteListProperty)[kTestServicePath2]); | 508 shill::kServiceCompleteListProperty)[kTestServicePath2]); |
509 EXPECT_EQ(1, listener_->property_updates( | 509 EXPECT_EQ(1, listener_->property_updates( |
510 shill::kServiceCompleteListProperty)[kTestServicePath2]); | 510 shill::kServiceCompleteListProperty)[kTestServicePath2]); |
511 } | 511 } |
512 | 512 |
513 } // namespace chromeos | 513 } // namespace chromeos |
OLD | NEW |