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

Side by Side Diff: chrome/browser/chromeos/cros/cros_network_functions_unittest.cc

Issue 10915106: Renaming instances of "flimflam" with "shill", now that we're only (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Upload after merge Created 8 years, 3 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
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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
7 #include "base/values.h" 7 #include "base/values.h"
8 #include "chrome/browser/chromeos/cros/cros_network_functions.h" 8 #include "chrome/browser/chromeos/cros/cros_network_functions.h"
9 #include "chrome/browser/chromeos/cros/sms_watcher.h" 9 #include "chrome/browser/chromeos/cros/sms_watcher.h"
10 #include "chromeos/dbus/mock_cashew_client.h" 10 #include "chromeos/dbus/mock_cashew_client.h"
11 #include "chromeos/dbus/mock_dbus_thread_manager.h" 11 #include "chromeos/dbus/mock_dbus_thread_manager.h"
12 #include "chromeos/dbus/mock_flimflam_device_client.h" 12 #include "chromeos/dbus/mock_shill_device_client.h"
13 #include "chromeos/dbus/mock_flimflam_ipconfig_client.h" 13 #include "chromeos/dbus/mock_shill_ipconfig_client.h"
14 #include "chromeos/dbus/mock_flimflam_manager_client.h" 14 #include "chromeos/dbus/mock_shill_manager_client.h"
15 #include "chromeos/dbus/mock_flimflam_network_client.h" 15 #include "chromeos/dbus/mock_shill_network_client.h"
16 #include "chromeos/dbus/mock_flimflam_profile_client.h" 16 #include "chromeos/dbus/mock_shill_profile_client.h"
17 #include "chromeos/dbus/mock_flimflam_service_client.h" 17 #include "chromeos/dbus/mock_shill_service_client.h"
18 #include "chromeos/dbus/mock_gsm_sms_client.h" 18 #include "chromeos/dbus/mock_gsm_sms_client.h"
19 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
20 #include "third_party/cros_system_api/dbus/service_constants.h" 20 #include "third_party/cros_system_api/dbus/service_constants.h"
21 21
22 using ::testing::_; 22 using ::testing::_;
23 using ::testing::Invoke; 23 using ::testing::Invoke;
24 using ::testing::Pointee; 24 using ::testing::Pointee;
25 using ::testing::Return; 25 using ::testing::Return;
26 using ::testing::SaveArg; 26 using ::testing::SaveArg;
27 using ::testing::StrEq; 27 using ::testing::StrEq;
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 CrosNetworkFunctionsTest() : mock_profile_client_(NULL), 153 CrosNetworkFunctionsTest() : mock_profile_client_(NULL),
154 dictionary_value_result_(NULL) {} 154 dictionary_value_result_(NULL) {}
155 155
156 virtual void SetUp() { 156 virtual void SetUp() {
157 MockDBusThreadManager* mock_dbus_thread_manager = new MockDBusThreadManager; 157 MockDBusThreadManager* mock_dbus_thread_manager = new MockDBusThreadManager;
158 EXPECT_CALL(*mock_dbus_thread_manager, GetSystemBus()) 158 EXPECT_CALL(*mock_dbus_thread_manager, GetSystemBus())
159 .WillRepeatedly(Return(reinterpret_cast<dbus::Bus*>(NULL))); 159 .WillRepeatedly(Return(reinterpret_cast<dbus::Bus*>(NULL)));
160 DBusThreadManager::InitializeForTesting(mock_dbus_thread_manager); 160 DBusThreadManager::InitializeForTesting(mock_dbus_thread_manager);
161 mock_cashew_client_ = mock_dbus_thread_manager->mock_cashew_client(); 161 mock_cashew_client_ = mock_dbus_thread_manager->mock_cashew_client();
162 mock_device_client_ = 162 mock_device_client_ =
163 mock_dbus_thread_manager->mock_flimflam_device_client(); 163 mock_dbus_thread_manager->mock_shill_device_client();
164 mock_ipconfig_client_ = 164 mock_ipconfig_client_ =
165 mock_dbus_thread_manager->mock_flimflam_ipconfig_client(); 165 mock_dbus_thread_manager->mock_shill_ipconfig_client();
166 mock_manager_client_ = 166 mock_manager_client_ =
167 mock_dbus_thread_manager->mock_flimflam_manager_client(); 167 mock_dbus_thread_manager->mock_shill_manager_client();
168 mock_network_client_ = 168 mock_network_client_ =
169 mock_dbus_thread_manager->mock_flimflam_network_client(); 169 mock_dbus_thread_manager->mock_shill_network_client();
170 mock_profile_client_ = 170 mock_profile_client_ =
171 mock_dbus_thread_manager->mock_flimflam_profile_client(); 171 mock_dbus_thread_manager->mock_shill_profile_client();
172 mock_service_client_ = 172 mock_service_client_ =
173 mock_dbus_thread_manager->mock_flimflam_service_client(); 173 mock_dbus_thread_manager->mock_shill_service_client();
174 mock_gsm_sms_client_ = mock_dbus_thread_manager->mock_gsm_sms_client(); 174 mock_gsm_sms_client_ = mock_dbus_thread_manager->mock_gsm_sms_client();
175 } 175 }
176 176
177 virtual void TearDown() { 177 virtual void TearDown() {
178 DBusThreadManager::Shutdown(); 178 DBusThreadManager::Shutdown();
179 mock_profile_client_ = NULL; 179 mock_profile_client_ = NULL;
180 } 180 }
181 181
182 // Handles responses for GetProperties method calls for FlimflamManagerClient. 182 // Handles responses for GetProperties method calls for ShillManagerClient.
183 void OnGetManagerProperties( 183 void OnGetManagerProperties(
184 const FlimflamClientHelper::DictionaryValueCallback& callback) { 184 const ShillClientHelper::DictionaryValueCallback& callback) {
185 callback.Run(DBUS_METHOD_CALL_SUCCESS, *dictionary_value_result_); 185 callback.Run(DBUS_METHOD_CALL_SUCCESS, *dictionary_value_result_);
186 } 186 }
187 187
188 // Handles responses for GetProperties method calls. 188 // Handles responses for GetProperties method calls.
189 void OnGetProperties( 189 void OnGetProperties(
190 const dbus::ObjectPath& path, 190 const dbus::ObjectPath& path,
191 const FlimflamClientHelper::DictionaryValueCallback& callback) { 191 const ShillClientHelper::DictionaryValueCallback& callback) {
192 callback.Run(DBUS_METHOD_CALL_SUCCESS, *dictionary_value_result_); 192 callback.Run(DBUS_METHOD_CALL_SUCCESS, *dictionary_value_result_);
193 } 193 }
194 194
195 // Handles responses for GetEntry method calls. 195 // Handles responses for GetEntry method calls.
196 void OnGetEntry( 196 void OnGetEntry(
197 const dbus::ObjectPath& profile_path, 197 const dbus::ObjectPath& profile_path,
198 const std::string& entry_path, 198 const std::string& entry_path,
199 const FlimflamClientHelper::DictionaryValueCallback& callback) { 199 const ShillClientHelper::DictionaryValueCallback& callback) {
200 callback.Run(DBUS_METHOD_CALL_SUCCESS, *dictionary_value_result_); 200 callback.Run(DBUS_METHOD_CALL_SUCCESS, *dictionary_value_result_);
201 } 201 }
202 202
203 // Mock NetworkOperationCallback. 203 // Mock NetworkOperationCallback.
204 MOCK_METHOD3(MockNetworkOperationCallback, 204 MOCK_METHOD3(MockNetworkOperationCallback,
205 void(const std::string& path, 205 void(const std::string& path,
206 NetworkMethodErrorType error, 206 NetworkMethodErrorType error,
207 const std::string& error_message)); 207 const std::string& error_message));
208 208
209 // Mock MonitorSMSCallback. 209 // Mock MonitorSMSCallback.
210 MOCK_METHOD2(MockMonitorSMSCallback, 210 MOCK_METHOD2(MockMonitorSMSCallback,
211 void(const std::string& modem_device_path, const SMS& message)); 211 void(const std::string& modem_device_path, const SMS& message));
212 212
213 protected: 213 protected:
214 MockCashewClient* mock_cashew_client_; 214 MockCashewClient* mock_cashew_client_;
215 MockFlimflamDeviceClient* mock_device_client_; 215 MockShillDeviceClient* mock_device_client_;
216 MockFlimflamIPConfigClient* mock_ipconfig_client_; 216 MockShillIPConfigClient* mock_ipconfig_client_;
217 MockFlimflamManagerClient* mock_manager_client_; 217 MockShillManagerClient* mock_manager_client_;
218 MockFlimflamNetworkClient* mock_network_client_; 218 MockShillNetworkClient* mock_network_client_;
219 MockFlimflamProfileClient* mock_profile_client_; 219 MockShillProfileClient* mock_profile_client_;
220 MockFlimflamServiceClient* mock_service_client_; 220 MockShillServiceClient* mock_service_client_;
221 MockGsmSMSClient* mock_gsm_sms_client_; 221 MockGsmSMSClient* mock_gsm_sms_client_;
222 const base::DictionaryValue* dictionary_value_result_; 222 const base::DictionaryValue* dictionary_value_result_;
223 }; 223 };
224 224
225 TEST_F(CrosNetworkFunctionsTest, CrosActivateCellularModem) { 225 TEST_F(CrosNetworkFunctionsTest, CrosActivateCellularModem) {
226 const std::string service_path = "/"; 226 const std::string service_path = "/";
227 const std::string carrier = "carrier"; 227 const std::string carrier = "carrier";
228 EXPECT_CALL(*mock_service_client_, 228 EXPECT_CALL(*mock_service_client_,
229 CallActivateCellularModemAndBlock(dbus::ObjectPath(service_path), 229 CallActivateCellularModemAndBlock(dbus::ObjectPath(service_path),
230 carrier)) 230 carrier))
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 EXPECT_CALL(*mock_cashew_client_, 305 EXPECT_CALL(*mock_cashew_client_,
306 RequestDataPlansUpdate(modem_service_path)).Times(1); 306 RequestDataPlansUpdate(modem_service_path)).Times(1);
307 CrosRequestCellularDataPlanUpdate(modem_service_path); 307 CrosRequestCellularDataPlanUpdate(modem_service_path);
308 } 308 }
309 309
310 TEST_F(CrosNetworkFunctionsTest, CrosMonitorNetworkManagerProperties) { 310 TEST_F(CrosNetworkFunctionsTest, CrosMonitorNetworkManagerProperties) {
311 const std::string key = "key"; 311 const std::string key = "key";
312 const int kValue = 42; 312 const int kValue = 42;
313 const base::FundamentalValue value(kValue); 313 const base::FundamentalValue value(kValue);
314 // Start monitoring. 314 // Start monitoring.
315 FlimflamClientHelper::PropertyChangedHandler handler; 315 ShillClientHelper::PropertyChangedHandler handler;
316 EXPECT_CALL(*mock_manager_client_, SetPropertyChangedHandler(_)) 316 EXPECT_CALL(*mock_manager_client_, SetPropertyChangedHandler(_))
317 .WillOnce(SaveArg<0>(&handler)); 317 .WillOnce(SaveArg<0>(&handler));
318 CrosNetworkWatcher* watcher = CrosMonitorNetworkManagerProperties( 318 CrosNetworkWatcher* watcher = CrosMonitorNetworkManagerProperties(
319 MockNetworkPropertiesWatcherCallback::CreateCallback( 319 MockNetworkPropertiesWatcherCallback::CreateCallback(
320 flimflam::kFlimflamServicePath, key, value)); 320 flimflam::kFlimflamServicePath, key, value));
321 // Call callback. 321 // Call callback.
322 handler.Run(key, value); 322 handler.Run(key, value);
323 // Stop monitoring. 323 // Stop monitoring.
324 EXPECT_CALL(*mock_manager_client_, ResetPropertyChangedHandler()).Times(1); 324 EXPECT_CALL(*mock_manager_client_, ResetPropertyChangedHandler()).Times(1);
325 delete watcher; 325 delete watcher;
326 } 326 }
327 327
328 TEST_F(CrosNetworkFunctionsTest, CrosMonitorNetworkServiceProperties) { 328 TEST_F(CrosNetworkFunctionsTest, CrosMonitorNetworkServiceProperties) {
329 const dbus::ObjectPath path("/path"); 329 const dbus::ObjectPath path("/path");
330 const std::string key = "key"; 330 const std::string key = "key";
331 const int kValue = 42; 331 const int kValue = 42;
332 const base::FundamentalValue value(kValue); 332 const base::FundamentalValue value(kValue);
333 // Start monitoring. 333 // Start monitoring.
334 FlimflamClientHelper::PropertyChangedHandler handler; 334 ShillClientHelper::PropertyChangedHandler handler;
335 EXPECT_CALL(*mock_service_client_, SetPropertyChangedHandler(path, _)) 335 EXPECT_CALL(*mock_service_client_, SetPropertyChangedHandler(path, _))
336 .WillOnce(SaveArg<1>(&handler)); 336 .WillOnce(SaveArg<1>(&handler));
337 NetworkPropertiesWatcherCallback callback = 337 NetworkPropertiesWatcherCallback callback =
338 MockNetworkPropertiesWatcherCallback::CreateCallback(path.value(), 338 MockNetworkPropertiesWatcherCallback::CreateCallback(path.value(),
339 key, value); 339 key, value);
340 CrosNetworkWatcher* watcher = CrosMonitorNetworkServiceProperties( 340 CrosNetworkWatcher* watcher = CrosMonitorNetworkServiceProperties(
341 callback, path.value()); 341 callback, path.value());
342 // Call callback. 342 // Call callback.
343 handler.Run(key, value); 343 handler.Run(key, value);
344 // Stop monitoring. 344 // Stop monitoring.
345 EXPECT_CALL(*mock_service_client_, 345 EXPECT_CALL(*mock_service_client_,
346 ResetPropertyChangedHandler(path)).Times(1); 346 ResetPropertyChangedHandler(path)).Times(1);
347 delete watcher; 347 delete watcher;
348 } 348 }
349 349
350 TEST_F(CrosNetworkFunctionsTest, CrosMonitorNetworkDeviceProperties) { 350 TEST_F(CrosNetworkFunctionsTest, CrosMonitorNetworkDeviceProperties) {
351 const dbus::ObjectPath path("/path"); 351 const dbus::ObjectPath path("/path");
352 const std::string key = "key"; 352 const std::string key = "key";
353 const int kValue = 42; 353 const int kValue = 42;
354 const base::FundamentalValue value(kValue); 354 const base::FundamentalValue value(kValue);
355 // Start monitoring. 355 // Start monitoring.
356 FlimflamClientHelper::PropertyChangedHandler handler; 356 ShillClientHelper::PropertyChangedHandler handler;
357 EXPECT_CALL(*mock_device_client_, SetPropertyChangedHandler(path, _)) 357 EXPECT_CALL(*mock_device_client_, SetPropertyChangedHandler(path, _))
358 .WillOnce(SaveArg<1>(&handler)); 358 .WillOnce(SaveArg<1>(&handler));
359 NetworkPropertiesWatcherCallback callback = 359 NetworkPropertiesWatcherCallback callback =
360 MockNetworkPropertiesWatcherCallback::CreateCallback(path.value(), 360 MockNetworkPropertiesWatcherCallback::CreateCallback(path.value(),
361 key, value); 361 key, value);
362 CrosNetworkWatcher* watcher = CrosMonitorNetworkDeviceProperties( 362 CrosNetworkWatcher* watcher = CrosMonitorNetworkDeviceProperties(
363 callback, path.value()); 363 callback, path.value());
364 // Call callback. 364 // Call callback.
365 handler.Run(key, value); 365 handler.Run(key, value);
366 // Stop monitoring. 366 // Stop monitoring.
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 sms.timestamp = timestamp; 483 sms.timestamp = timestamp;
484 sms.number = number.c_str(); 484 sms.number = number.c_str();
485 sms.text = text.c_str(); 485 sms.text = text.c_str();
486 sms.smsc = smsc.c_str(); 486 sms.smsc = smsc.c_str();
487 sms.validity = kValidity; 487 sms.validity = kValidity;
488 sms.msgclass = kMsgclass; 488 sms.msgclass = kMsgclass;
489 489
490 const std::string modem_device_path = "/modem/device/path"; 490 const std::string modem_device_path = "/modem/device/path";
491 491
492 // Set expectations. 492 // Set expectations.
493 FlimflamDeviceClient::DictionaryValueCallback get_properties_callback; 493 ShillDeviceClient::DictionaryValueCallback get_properties_callback;
494 EXPECT_CALL(*mock_device_client_, 494 EXPECT_CALL(*mock_device_client_,
495 GetProperties(dbus::ObjectPath(modem_device_path), _)) 495 GetProperties(dbus::ObjectPath(modem_device_path), _))
496 .WillOnce(SaveArg<1>(&get_properties_callback)); 496 .WillOnce(SaveArg<1>(&get_properties_callback));
497 GsmSMSClient::SmsReceivedHandler sms_received_handler; 497 GsmSMSClient::SmsReceivedHandler sms_received_handler;
498 EXPECT_CALL(*mock_gsm_sms_client_, 498 EXPECT_CALL(*mock_gsm_sms_client_,
499 SetSmsReceivedHandler(dbus_connection, object_path, _)) 499 SetSmsReceivedHandler(dbus_connection, object_path, _))
500 .WillOnce(SaveArg<2>(&sms_received_handler)); 500 .WillOnce(SaveArg<2>(&sms_received_handler));
501 501
502 GsmSMSClient::ListCallback list_callback; 502 GsmSMSClient::ListCallback list_callback;
503 EXPECT_CALL(*mock_gsm_sms_client_, List(dbus_connection, object_path, _)) 503 EXPECT_CALL(*mock_gsm_sms_client_, List(dbus_connection, object_path, _))
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 const std::string security = "security"; 656 const std::string security = "security";
657 const std::string key1 = "key1"; 657 const std::string key1 = "key1";
658 const std::string value1 = "value1"; 658 const std::string value1 = "value1";
659 const std::string key2 = "key.2."; 659 const std::string key2 = "key.2.";
660 const std::string value2 = "value2"; 660 const std::string value2 = "value2";
661 // Create result value. 661 // Create result value.
662 base::DictionaryValue result; 662 base::DictionaryValue result;
663 result.SetWithoutPathExpansion(key1, base::Value::CreateStringValue(value1)); 663 result.SetWithoutPathExpansion(key1, base::Value::CreateStringValue(value1));
664 result.SetWithoutPathExpansion(key2, base::Value::CreateStringValue(value2)); 664 result.SetWithoutPathExpansion(key2, base::Value::CreateStringValue(value2));
665 dictionary_value_result_ = &result; 665 dictionary_value_result_ = &result;
666 // Create expected argument to FlimflamManagerClient::GetService. 666 // Create expected argument to ShillManagerClient::GetService.
667 base::DictionaryValue properties; 667 base::DictionaryValue properties;
668 properties.SetWithoutPathExpansion( 668 properties.SetWithoutPathExpansion(
669 flimflam::kModeProperty, 669 flimflam::kModeProperty,
670 base::Value::CreateStringValue(flimflam::kModeManaged)); 670 base::Value::CreateStringValue(flimflam::kModeManaged));
671 properties.SetWithoutPathExpansion( 671 properties.SetWithoutPathExpansion(
672 flimflam::kTypeProperty, 672 flimflam::kTypeProperty,
673 base::Value::CreateStringValue(flimflam::kTypeWifi)); 673 base::Value::CreateStringValue(flimflam::kTypeWifi));
674 properties.SetWithoutPathExpansion( 674 properties.SetWithoutPathExpansion(
675 flimflam::kSSIDProperty, 675 flimflam::kSSIDProperty,
676 base::Value::CreateStringValue(ssid)); 676 base::Value::CreateStringValue(ssid));
(...skipping 24 matching lines...) Expand all
701 const std::string provider_type = "provider type"; 701 const std::string provider_type = "provider type";
702 const std::string key1 = "key1"; 702 const std::string key1 = "key1";
703 const std::string value1 = "value1"; 703 const std::string value1 = "value1";
704 const std::string key2 = "key.2."; 704 const std::string key2 = "key.2.";
705 const std::string value2 = "value2"; 705 const std::string value2 = "value2";
706 // Create result value. 706 // Create result value.
707 base::DictionaryValue result; 707 base::DictionaryValue result;
708 result.SetWithoutPathExpansion(key1, base::Value::CreateStringValue(value1)); 708 result.SetWithoutPathExpansion(key1, base::Value::CreateStringValue(value1));
709 result.SetWithoutPathExpansion(key2, base::Value::CreateStringValue(value2)); 709 result.SetWithoutPathExpansion(key2, base::Value::CreateStringValue(value2));
710 dictionary_value_result_ = &result; 710 dictionary_value_result_ = &result;
711 // Create expected argument to FlimflamManagerClient::GetService. 711 // Create expected argument to ShillManagerClient::GetService.
712 base::DictionaryValue properties; 712 base::DictionaryValue properties;
713 properties.SetWithoutPathExpansion( 713 properties.SetWithoutPathExpansion(
714 flimflam::kTypeProperty, base::Value::CreateStringValue("vpn")); 714 flimflam::kTypeProperty, base::Value::CreateStringValue("vpn"));
715 properties.SetWithoutPathExpansion( 715 properties.SetWithoutPathExpansion(
716 flimflam::kProviderNameProperty, 716 flimflam::kProviderNameProperty,
717 base::Value::CreateStringValue(service_name)); 717 base::Value::CreateStringValue(service_name));
718 properties.SetWithoutPathExpansion( 718 properties.SetWithoutPathExpansion(
719 flimflam::kProviderHostProperty, 719 flimflam::kProviderHostProperty,
720 base::Value::CreateStringValue(server_hostname)); 720 base::Value::CreateStringValue(server_hostname));
721 properties.SetWithoutPathExpansion( 721 properties.SetWithoutPathExpansion(
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
1147 EXPECT_EQ("192.0.0.0", CrosPrefixLengthToNetmask(2)); 1147 EXPECT_EQ("192.0.0.0", CrosPrefixLengthToNetmask(2));
1148 EXPECT_EQ("128.0.0.0", CrosPrefixLengthToNetmask(1)); 1148 EXPECT_EQ("128.0.0.0", CrosPrefixLengthToNetmask(1));
1149 EXPECT_EQ("0.0.0.0", CrosPrefixLengthToNetmask(0)); 1149 EXPECT_EQ("0.0.0.0", CrosPrefixLengthToNetmask(0));
1150 // Invalid Prefix Lengths 1150 // Invalid Prefix Lengths
1151 EXPECT_EQ("", CrosPrefixLengthToNetmask(-1)); 1151 EXPECT_EQ("", CrosPrefixLengthToNetmask(-1));
1152 EXPECT_EQ("", CrosPrefixLengthToNetmask(33)); 1152 EXPECT_EQ("", CrosPrefixLengthToNetmask(33));
1153 EXPECT_EQ("", CrosPrefixLengthToNetmask(255)); 1153 EXPECT_EQ("", CrosPrefixLengthToNetmask(255));
1154 } 1154 }
1155 1155
1156 } // namespace chromeos 1156 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/cros/cros_network_functions.cc ('k') | chrome/browser/chromeos/cros/native_network_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698