Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(293)

Side by Side Diff: chromeos/network/network_change_notifier_chromeos_unittest.cc

Issue 11620007: Switch from OnIPAddressChanged and OnConnectionTypeChange to OnNetworkChanged Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_change_notifier_chromeos.h" 5 #include "chromeos/network/network_change_notifier_chromeos.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/message_loop.h"
10 #include "chromeos/network/network_change_notifier_factory_chromeos.h" 11 #include "chromeos/network/network_change_notifier_factory_chromeos.h"
11 #include "chromeos/network/network_state.h" 12 #include "chromeos/network/network_state.h"
12 #include "net/base/network_change_notifier.h" 13 #include "net/base/network_change_notifier.h"
13 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
14 #include "third_party/cros_system_api/dbus/service_constants.h" 15 #include "third_party/cros_system_api/dbus/service_constants.h"
15 16
16 namespace chromeos { 17 namespace chromeos {
17 18
18 using net::NetworkChangeNotifier; 19 using net::NetworkChangeNotifier;
19 20
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 // Process an default network update based on the state of |default_network_|. 103 // Process an default network update based on the state of |default_network_|.
103 void ProcessDefaultNetworkUpdate(bool* type_changed, 104 void ProcessDefaultNetworkUpdate(bool* type_changed,
104 bool* ip_changed, 105 bool* ip_changed,
105 bool* dns_changed) { 106 bool* dns_changed) {
106 notifier_.UpdateState(&default_network_, type_changed, ip_changed, 107 notifier_.UpdateState(&default_network_, type_changed, ip_changed,
107 dns_changed); 108 dns_changed);
108 } 109 }
109 110
110 private: 111 private:
111 NetworkState default_network_; 112 NetworkState default_network_;
113 MessageLoop message_loop_;
112 NetworkChangeNotifierChromeos notifier_; 114 NetworkChangeNotifierChromeos notifier_;
113 }; 115 };
114 116
115 TEST_F(NetworkChangeNotifierChromeosUpdateTest, UpdateDefaultNetworkOffline) { 117 TEST_F(NetworkChangeNotifierChromeosUpdateTest, UpdateDefaultNetworkOffline) {
116 // Test that Online to Offline transitions are correctly handled. 118 // Test that Online to Offline transitions are correctly handled.
117 SetNotifierState(NetworkChangeNotifier::CONNECTION_ETHERNET, "/service/1", 119 SetNotifierState(NetworkChangeNotifier::CONNECTION_ETHERNET, "/service/1",
118 "192.168.1.1"); 120 "192.168.1.1");
119 SetDefaultNetworkState(false, // offline. 121 SetDefaultNetworkState(false, // offline.
120 flimflam::kTypeEthernet, "", "/service/1", ""); 122 flimflam::kTypeEthernet, "", "/service/1", "");
121 bool type_changed = false, ip_changed = false, dns_changed = false; 123 bool type_changed = false, ip_changed = false, dns_changed = false;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 VerifyNotifierState(NetworkChangeNotifier::CONNECTION_WIFI, "/service/3", 178 VerifyNotifierState(NetworkChangeNotifier::CONNECTION_WIFI, "/service/3",
177 "192.168.1.2" ); 179 "192.168.1.2" );
178 EXPECT_FALSE(type_changed); 180 EXPECT_FALSE(type_changed);
179 // A service path change (even with a corresponding IP change) should still 181 // A service path change (even with a corresponding IP change) should still
180 // trigger an IP address update to observers. 182 // trigger an IP address update to observers.
181 EXPECT_TRUE(ip_changed); 183 EXPECT_TRUE(ip_changed);
182 EXPECT_TRUE(dns_changed); 184 EXPECT_TRUE(dns_changed);
183 } 185 }
184 186
185 } // namespace chromeos 187 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698