OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "chrome/browser/chromeos/network_state_notifier.h" | 5 #include "chrome/browser/chromeos/network_state_notifier.h" |
6 | 6 |
7 #include "chrome/browser/browser_thread.h" | 7 #include "chrome/browser/browser_thread.h" |
8 #include "chrome/browser/chromeos/cros/cros_in_process_browser_test.h" | 8 #include "chrome/browser/chromeos/cros/cros_in_process_browser_test.h" |
9 #include "chrome/browser/chromeos/cros/mock_network_library.h" | 9 #include "chrome/browser/chromeos/cros/mock_network_library.h" |
10 #include "chrome/common/notification_registrar.h" | 10 #include "chrome/common/notification_registrar.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 IN_PROC_BROWSER_TEST_F(NetworkStateNotifierTest, TestConnected) { | 63 IN_PROC_BROWSER_TEST_F(NetworkStateNotifierTest, TestConnected) { |
64 // NETWORK_STATE_CHAGNED has to be registered in UI thread. | 64 // NETWORK_STATE_CHAGNED has to be registered in UI thread. |
65 NotificationRegistrar registrar; | 65 NotificationRegistrar registrar; |
66 registrar.Add(this, NotificationType::NETWORK_STATE_CHANGED, | 66 registrar.Add(this, NotificationType::NETWORK_STATE_CHANGED, |
67 NotificationService::AllSources()); | 67 NotificationService::AllSources()); |
68 EXPECT_CALL(*mock_network_library_, Connected()) | 68 EXPECT_CALL(*mock_network_library_, Connected()) |
69 .Times(1) | 69 .Times(1) |
70 .WillRepeatedly((Return(true))) | 70 .WillRepeatedly((Return(true))) |
71 .RetiresOnSaturation(); | 71 .RetiresOnSaturation(); |
72 NetworkStateNotifier* notifier = NetworkStateNotifier::Get(); | 72 NetworkStateNotifier* notifier = NetworkStateNotifier::Get(); |
73 notifier->NetworkChanged(mock_network_library_); | 73 notifier->OnNetworkManagerChanged(mock_network_library_); |
74 WaitForNotification(); | 74 WaitForNotification(); |
75 EXPECT_EQ(chromeos::NetworkStateDetails::CONNECTED, state_); | 75 EXPECT_EQ(chromeos::NetworkStateDetails::CONNECTED, state_); |
76 } | 76 } |
77 | 77 |
78 IN_PROC_BROWSER_TEST_F(NetworkStateNotifierTest, TestConnecting) { | 78 IN_PROC_BROWSER_TEST_F(NetworkStateNotifierTest, TestConnecting) { |
79 NotificationRegistrar registrar; | 79 NotificationRegistrar registrar; |
80 registrar.Add(this, NotificationType::NETWORK_STATE_CHANGED, | 80 registrar.Add(this, NotificationType::NETWORK_STATE_CHANGED, |
81 NotificationService::AllSources()); | 81 NotificationService::AllSources()); |
82 EXPECT_CALL(*mock_network_library_, Connected()) | 82 EXPECT_CALL(*mock_network_library_, Connected()) |
83 .Times(1) | 83 .Times(1) |
84 .WillOnce((Return(false))) | 84 .WillOnce((Return(false))) |
85 .RetiresOnSaturation(); | 85 .RetiresOnSaturation(); |
86 EXPECT_CALL(*mock_network_library_, Connecting()) | 86 EXPECT_CALL(*mock_network_library_, Connecting()) |
87 .Times(1) | 87 .Times(1) |
88 .WillOnce((Return(true))) | 88 .WillOnce((Return(true))) |
89 .RetiresOnSaturation(); | 89 .RetiresOnSaturation(); |
90 NetworkStateNotifier* notifier = NetworkStateNotifier::Get(); | 90 NetworkStateNotifier* notifier = NetworkStateNotifier::Get(); |
91 notifier->NetworkChanged(mock_network_library_); | 91 notifier->OnNetworkManagerChanged(mock_network_library_); |
92 WaitForNotification(); | 92 WaitForNotification(); |
93 EXPECT_EQ(chromeos::NetworkStateDetails::CONNECTING, state_); | 93 EXPECT_EQ(chromeos::NetworkStateDetails::CONNECTING, state_); |
94 } | 94 } |
95 | 95 |
96 IN_PROC_BROWSER_TEST_F(NetworkStateNotifierTest, TestDisconnected) { | 96 IN_PROC_BROWSER_TEST_F(NetworkStateNotifierTest, TestDisconnected) { |
97 NotificationRegistrar registrar; | 97 NotificationRegistrar registrar; |
98 registrar.Add(this, NotificationType::NETWORK_STATE_CHANGED, | 98 registrar.Add(this, NotificationType::NETWORK_STATE_CHANGED, |
99 NotificationService::AllSources()); | 99 NotificationService::AllSources()); |
100 EXPECT_CALL(*mock_network_library_, Connected()) | 100 EXPECT_CALL(*mock_network_library_, Connected()) |
101 .Times(1) | 101 .Times(1) |
102 .WillOnce((Return(false))) | 102 .WillOnce((Return(false))) |
103 .RetiresOnSaturation(); | 103 .RetiresOnSaturation(); |
104 EXPECT_CALL(*mock_network_library_, Connecting()) | 104 EXPECT_CALL(*mock_network_library_, Connecting()) |
105 .Times(1) | 105 .Times(1) |
106 .WillOnce((Return(false))) | 106 .WillOnce((Return(false))) |
107 .RetiresOnSaturation(); | 107 .RetiresOnSaturation(); |
108 NetworkStateNotifier* notifier = NetworkStateNotifier::Get(); | 108 NetworkStateNotifier* notifier = NetworkStateNotifier::Get(); |
109 notifier->NetworkChanged(mock_network_library_); | 109 notifier->OnNetworkManagerChanged(mock_network_library_); |
110 WaitForNotification(); | 110 WaitForNotification(); |
111 EXPECT_EQ(chromeos::NetworkStateDetails::DISCONNECTED, state_); | 111 EXPECT_EQ(chromeos::NetworkStateDetails::DISCONNECTED, state_); |
112 } | 112 } |
113 | 113 |
114 } // namespace chromeos | 114 } // namespace chromeos |
OLD | NEW |