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/network_state_handler.h" | 5 #include "chromeos/network/network_state_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 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 network_state_handler_->GetTechnologyState(flimflam::kTypeWimax)); | 255 network_state_handler_->GetTechnologyState(flimflam::kTypeWimax)); |
256 | 256 |
257 manager_test->RemoveTechnology(flimflam::kTypeWimax); | 257 manager_test->RemoveTechnology(flimflam::kTypeWimax); |
258 message_loop_.RunUntilIdle(); | 258 message_loop_.RunUntilIdle(); |
259 EXPECT_EQ(NetworkStateHandler::TECHNOLOGY_UNAVAILABLE, | 259 EXPECT_EQ(NetworkStateHandler::TECHNOLOGY_UNAVAILABLE, |
260 network_state_handler_->GetTechnologyState(flimflam::kTypeWimax)); | 260 network_state_handler_->GetTechnologyState(flimflam::kTypeWimax)); |
261 } | 261 } |
262 | 262 |
263 TEST_F(NetworkStateHandlerTest, ServicePropertyChanged) { | 263 TEST_F(NetworkStateHandlerTest, ServicePropertyChanged) { |
264 // Set a service property. | 264 // Set a service property. |
265 const std::string eth0 = "stub_ethernet"; | 265 const std::string eth0 = kShillManagerClientStubDefaultService; |
266 EXPECT_EQ("", network_state_handler_->GetNetworkState(eth0)->security()); | 266 EXPECT_EQ("", network_state_handler_->GetNetworkState(eth0)->security()); |
267 EXPECT_EQ(1, test_observer_->PropertyUpdatesForService(eth0)); | 267 EXPECT_EQ(1, test_observer_->PropertyUpdatesForService(eth0)); |
268 base::StringValue security_value("TestSecurity"); | 268 base::StringValue security_value("TestSecurity"); |
269 DBusThreadManager::Get()->GetShillServiceClient()->SetProperty( | 269 DBusThreadManager::Get()->GetShillServiceClient()->SetProperty( |
270 dbus::ObjectPath(eth0), | 270 dbus::ObjectPath(eth0), |
271 flimflam::kSecurityProperty, security_value, | 271 flimflam::kSecurityProperty, security_value, |
272 base::Bind(&base::DoNothing), base::Bind(&ErrorCallbackFunction)); | 272 base::Bind(&base::DoNothing), base::Bind(&ErrorCallbackFunction)); |
273 message_loop_.RunUntilIdle(); | 273 message_loop_.RunUntilIdle(); |
274 EXPECT_EQ("TestSecurity", | 274 EXPECT_EQ("TestSecurity", |
275 network_state_handler_->GetNetworkState(eth0)->security()); | 275 network_state_handler_->GetNetworkState(eth0)->security()); |
276 EXPECT_EQ(2, test_observer_->PropertyUpdatesForService(eth0)); | 276 EXPECT_EQ(2, test_observer_->PropertyUpdatesForService(eth0)); |
277 } | 277 } |
278 | 278 |
279 TEST_F(NetworkStateHandlerTest, NetworkConnectionStateChanged) { | 279 TEST_F(NetworkStateHandlerTest, NetworkConnectionStateChanged) { |
280 // Change a network state. | 280 // Change a network state. |
281 ShillServiceClient::TestInterface* service_test = | 281 ShillServiceClient::TestInterface* service_test = |
282 DBusThreadManager::Get()->GetShillServiceClient()->GetTestInterface(); | 282 DBusThreadManager::Get()->GetShillServiceClient()->GetTestInterface(); |
283 const std::string eth0 = "stub_ethernet"; | 283 const std::string eth0 = kShillManagerClientStubDefaultService; |
284 base::StringValue connection_state_idle_value(flimflam::kStateIdle); | 284 base::StringValue connection_state_idle_value(flimflam::kStateIdle); |
285 service_test->SetServiceProperty(eth0, flimflam::kStateProperty, | 285 service_test->SetServiceProperty(eth0, flimflam::kStateProperty, |
286 connection_state_idle_value); | 286 connection_state_idle_value); |
287 message_loop_.RunUntilIdle(); | 287 message_loop_.RunUntilIdle(); |
288 EXPECT_EQ(flimflam::kStateIdle, | 288 EXPECT_EQ(flimflam::kStateIdle, |
289 test_observer_->NetworkConnectionStateForService(eth0)); | 289 test_observer_->NetworkConnectionStateForService(eth0)); |
290 EXPECT_EQ(2, test_observer_->ConnectionStateChangesForService(eth0)); | 290 EXPECT_EQ(2, test_observer_->ConnectionStateChangesForService(eth0)); |
291 // Confirm that changing the connection state to the same value does *not* | 291 // Confirm that changing the connection state to the same value does *not* |
292 // signal the observer. | 292 // signal the observer. |
293 service_test->SetServiceProperty(eth0, flimflam::kStateProperty, | 293 service_test->SetServiceProperty(eth0, flimflam::kStateProperty, |
294 connection_state_idle_value); | 294 connection_state_idle_value); |
295 message_loop_.RunUntilIdle(); | 295 message_loop_.RunUntilIdle(); |
296 EXPECT_EQ(2, test_observer_->ConnectionStateChangesForService(eth0)); | 296 EXPECT_EQ(2, test_observer_->ConnectionStateChangesForService(eth0)); |
297 } | 297 } |
298 | 298 |
299 TEST_F(NetworkStateHandlerTest, DefaultServiceChanged) { | 299 TEST_F(NetworkStateHandlerTest, DefaultServiceChanged) { |
300 ShillManagerClient::TestInterface* manager_test = | 300 ShillManagerClient::TestInterface* manager_test = |
301 DBusThreadManager::Get()->GetShillManagerClient()->GetTestInterface(); | 301 DBusThreadManager::Get()->GetShillManagerClient()->GetTestInterface(); |
302 ASSERT_TRUE(manager_test); | 302 ASSERT_TRUE(manager_test); |
303 ShillServiceClient::TestInterface* service_test = | 303 ShillServiceClient::TestInterface* service_test = |
304 DBusThreadManager::Get()->GetShillServiceClient()->GetTestInterface(); | 304 DBusThreadManager::Get()->GetShillServiceClient()->GetTestInterface(); |
305 ASSERT_TRUE(service_test); | 305 ASSERT_TRUE(service_test); |
306 | 306 |
307 // Change the default network by inserting wifi1 at the front of the list | 307 // Change the default network by moving wifi1 to the front of the list |
308 // and changing the state of stub_ethernet to Idle. | 308 // and changing the state of stub_ethernet to Idle. |
309 const std::string wifi1 = "stub_wifi1"; | 309 const std::string wifi1 = kShillManagerClientStubDefaultWireless; |
310 manager_test->AddServiceAtIndex(wifi1, 0, true); | 310 manager_test->MoveServiceToIndex(wifi1, 0, true); |
311 const std::string eth0 = "stub_ethernet"; | 311 const std::string eth0 = kShillManagerClientStubDefaultService; |
312 base::StringValue connection_state_idle_value(flimflam::kStateIdle); | 312 base::StringValue connection_state_idle_value(flimflam::kStateIdle); |
313 service_test->SetServiceProperty(eth0, flimflam::kStateProperty, | 313 service_test->SetServiceProperty(eth0, flimflam::kStateProperty, |
314 connection_state_idle_value); | 314 connection_state_idle_value); |
315 message_loop_.RunUntilIdle(); | 315 message_loop_.RunUntilIdle(); |
316 EXPECT_EQ(wifi1, test_observer_->default_network()); | 316 EXPECT_EQ(wifi1, test_observer_->default_network()); |
317 EXPECT_EQ(flimflam::kStateOnline, | 317 EXPECT_EQ(flimflam::kStateOnline, |
318 test_observer_->default_network_connection_state()); | 318 test_observer_->default_network_connection_state()); |
319 // We should have seen 2 default network updates - for the default | 319 // We should have seen 2 default network updates - for the default |
320 // service change, and for the state change. | 320 // service change, and for the state change. |
321 EXPECT_EQ(2u, test_observer_->default_network_change_count()); | 321 EXPECT_EQ(2u, test_observer_->default_network_change_count()); |
(...skipping 10 matching lines...) Expand all Loading... |
332 // No default network updates for signal strength changes. | 332 // No default network updates for signal strength changes. |
333 DBusThreadManager::Get()->GetShillServiceClient()->SetProperty( | 333 DBusThreadManager::Get()->GetShillServiceClient()->SetProperty( |
334 dbus::ObjectPath(wifi1), | 334 dbus::ObjectPath(wifi1), |
335 flimflam::kSignalStrengthProperty, base::FundamentalValue(32), | 335 flimflam::kSignalStrengthProperty, base::FundamentalValue(32), |
336 base::Bind(&base::DoNothing), base::Bind(&ErrorCallbackFunction)); | 336 base::Bind(&base::DoNothing), base::Bind(&ErrorCallbackFunction)); |
337 message_loop_.RunUntilIdle(); | 337 message_loop_.RunUntilIdle(); |
338 EXPECT_EQ(3u, test_observer_->default_network_change_count()); | 338 EXPECT_EQ(3u, test_observer_->default_network_change_count()); |
339 } | 339 } |
340 | 340 |
341 } // namespace chromeos | 341 } // namespace chromeos |
OLD | NEW |