| 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 "ash/system/chromeos/network/network_state_notifier.h" | 5 #include "ash/system/chromeos/network/network_state_notifier.h" |
| 6 | 6 |
| 7 #include "ash/root_window_controller.h" | 7 #include "ash/root_window_controller.h" |
| 8 #include "ash/shelf/shelf_widget.h" | 8 #include "ash/shelf/shelf_widget.h" |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "ash/system/chromeos/network/network_connect.h" | 10 #include "ash/system/chromeos/network/network_connect.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 DBusThreadManager::Get()->GetShillDeviceClient()->GetTestInterface(); | 63 DBusThreadManager::Get()->GetShillDeviceClient()->GetTestInterface(); |
| 64 device_test->ClearDevices(); | 64 device_test->ClearDevices(); |
| 65 device_test->AddDevice("/device/stub_wifi_device1", | 65 device_test->AddDevice("/device/stub_wifi_device1", |
| 66 shill::kTypeWifi, "stub_wifi_device1"); | 66 shill::kTypeWifi, "stub_wifi_device1"); |
| 67 device_test->AddDevice("/device/stub_cellular_device1", | 67 device_test->AddDevice("/device/stub_cellular_device1", |
| 68 shill::kTypeCellular, "stub_cellular_device1"); | 68 shill::kTypeCellular, "stub_cellular_device1"); |
| 69 | 69 |
| 70 ShillServiceClient::TestInterface* service_test = | 70 ShillServiceClient::TestInterface* service_test = |
| 71 DBusThreadManager::Get()->GetShillServiceClient()->GetTestInterface(); | 71 DBusThreadManager::Get()->GetShillServiceClient()->GetTestInterface(); |
| 72 service_test->ClearServices(); | 72 service_test->ClearServices(); |
| 73 const bool add_to_watchlist = true; | |
| 74 const bool add_to_visible = true; | 73 const bool add_to_visible = true; |
| 75 // Create wifi and cellular networks and set to online. | 74 // Create wifi and cellular networks and set to online. |
| 76 service_test->AddService("wifi1", "wifi1", | 75 service_test->AddService("wifi1", "wifi1", |
| 77 shill::kTypeWifi, shill::kStateIdle, | 76 shill::kTypeWifi, shill::kStateIdle, |
| 78 add_to_visible, add_to_watchlist); | 77 add_to_visible); |
| 79 service_test->SetServiceProperty("wifi1", | 78 service_test->SetServiceProperty("wifi1", |
| 80 shill::kSecurityProperty, | 79 shill::kSecurityProperty, |
| 81 base::StringValue(shill::kSecurityWep)); | 80 base::StringValue(shill::kSecurityWep)); |
| 82 service_test->SetServiceProperty("wifi1", | 81 service_test->SetServiceProperty("wifi1", |
| 83 shill::kConnectableProperty, | 82 shill::kConnectableProperty, |
| 84 base::FundamentalValue(true)); | 83 base::FundamentalValue(true)); |
| 85 service_test->SetServiceProperty("wifi1", | 84 service_test->SetServiceProperty("wifi1", |
| 86 shill::kPassphraseProperty, | 85 shill::kPassphraseProperty, |
| 87 base::StringValue("failure")); | 86 base::StringValue("failure")); |
| 88 RunAllPendingInMessageLoop(); | 87 RunAllPendingInMessageLoop(); |
| 89 } | 88 } |
| 90 | 89 |
| 91 private: | 90 private: |
| 92 DISALLOW_COPY_AND_ASSIGN(NetworkStateNotifierTest); | 91 DISALLOW_COPY_AND_ASSIGN(NetworkStateNotifierTest); |
| 93 }; | 92 }; |
| 94 | 93 |
| 95 TEST_F(NetworkStateNotifierTest, ConnectionFailure) { | 94 TEST_F(NetworkStateNotifierTest, ConnectionFailure) { |
| 96 EXPECT_FALSE(GetSystemTray()->HasNotificationBubble()); | 95 EXPECT_FALSE(GetSystemTray()->HasNotificationBubble()); |
| 97 ash::network_connect::ConnectToNetwork("wifi1", NULL /* owning_window */); | 96 ash::network_connect::ConnectToNetwork("wifi1", NULL /* owning_window */); |
| 98 RunAllPendingInMessageLoop(); | 97 RunAllPendingInMessageLoop(); |
| 99 // Failure should spawn a notification. | 98 // Failure should spawn a notification. |
| 100 message_center::MessageCenter* message_center = | 99 message_center::MessageCenter* message_center = |
| 101 message_center::MessageCenter::Get(); | 100 message_center::MessageCenter::Get(); |
| 102 EXPECT_TRUE(message_center->HasNotification( | 101 EXPECT_TRUE(message_center->HasNotification( |
| 103 network_connect::kNetworkConnectNotificationId)); | 102 network_connect::kNetworkConnectNotificationId)); |
| 104 } | 103 } |
| 105 | 104 |
| 106 } // namespace test | 105 } // namespace test |
| 107 } // namespace ash | 106 } // namespace ash |
| OLD | NEW |