| Index: chrome/browser/chromeos/cros/cros_network_functions_unittest.cc
|
| diff --git a/chrome/browser/chromeos/cros/cros_network_functions_unittest.cc b/chrome/browser/chromeos/cros/cros_network_functions_unittest.cc
|
| index 8ce527cc39f4a0b93c489e13d88ed37756382d2d..bb8660111ece7fc42926dd7227942b9a86df9667 100644
|
| --- a/chrome/browser/chromeos/cros/cros_network_functions_unittest.cc
|
| +++ b/chrome/browser/chromeos/cros/cros_network_functions_unittest.cc
|
| @@ -54,20 +54,28 @@ class MockNetworkPropertiesCallback {
|
| // Creates a NetworkPropertiesCallback with expectations.
|
| static NetworkPropertiesCallback CreateCallback(
|
| const std::string& expected_path,
|
| - const base::DictionaryValue& expected_result) {
|
| + base::DictionaryValue& expected_result) {
|
| MockNetworkPropertiesCallback* mock_callback =
|
| new MockNetworkPropertiesCallback;
|
|
|
| EXPECT_CALL(*mock_callback,
|
| - Run(expected_path, Pointee(IsEqualTo(&expected_result))))
|
| + RunMock(expected_path, Pointee(IsEqualTo(&expected_result))))
|
| .Times(1);
|
|
|
| return base::Bind(&MockNetworkPropertiesCallback::Run,
|
| base::Owned(mock_callback));
|
| }
|
|
|
| - MOCK_METHOD2(Run, void(const std::string& path,
|
| - const base::DictionaryValue* result));
|
| + // We have to implement this as a non-mock and call the mock function because
|
| + // mocks don't play well with scoped_ptr arguments because they are movable
|
| + // but not copyable. Expectations are placed on the RunMock function instead.
|
| + void Run(const std::string& path,
|
| + scoped_ptr<base::DictionaryValue> result) {
|
| + RunMock(path, result.get());
|
| + }
|
| +
|
| + MOCK_METHOD2(RunMock, void(const std::string& path,
|
| + base::DictionaryValue* result));
|
| };
|
|
|
| // A mock to check arguments of NetworkPropertiesWatcherCallback and ensure that
|
| @@ -181,15 +189,19 @@ class CrosNetworkFunctionsTest : public testing::Test {
|
|
|
| // Handles responses for GetProperties method calls for ShillManagerClient.
|
| void OnGetManagerProperties(
|
| - const ShillClientHelper::DictionaryValueCallback& callback) {
|
| - callback.Run(DBUS_METHOD_CALL_SUCCESS, *dictionary_value_result_);
|
| + const ShillClientHelper::DictionaryValueCallback& callback) {
|
| + scoped_ptr<base::DictionaryValue> result_copy(
|
| + dictionary_value_result_->DeepCopy());
|
| + callback.Run(DBUS_METHOD_CALL_SUCCESS, result_copy.Pass());
|
| }
|
|
|
| // Handles responses for GetProperties method calls.
|
| void OnGetProperties(
|
| const dbus::ObjectPath& path,
|
| const ShillClientHelper::DictionaryValueCallback& callback) {
|
| - callback.Run(DBUS_METHOD_CALL_SUCCESS, *dictionary_value_result_);
|
| + scoped_ptr<base::DictionaryValue> result_copy(
|
| + dictionary_value_result_->DeepCopy());
|
| + callback.Run(DBUS_METHOD_CALL_SUCCESS, result_copy.Pass());
|
| }
|
|
|
| // Handles responses for GetProperties method calls that return
|
| @@ -198,7 +210,9 @@ class CrosNetworkFunctionsTest : public testing::Test {
|
| const dbus::ObjectPath& path,
|
| const ShillClientHelper::DictionaryValueCallbackWithoutStatus& callback,
|
| const ShillClientHelper::ErrorCallback& error_callback) {
|
| - callback.Run(*dictionary_value_result_);
|
| + scoped_ptr<base::DictionaryValue> result_copy(
|
| + dictionary_value_result_->DeepCopy());
|
| + callback.Run(result_copy.Pass());
|
| }
|
|
|
| // Handles responses for GetEntry method calls.
|
| @@ -207,7 +221,9 @@ class CrosNetworkFunctionsTest : public testing::Test {
|
| const std::string& entry_path,
|
| const ShillClientHelper::DictionaryValueCallbackWithoutStatus& callback,
|
| const ShillClientHelper::ErrorCallback& error_callback) {
|
| - callback.Run(*dictionary_value_result_);
|
| + scoped_ptr<base::DictionaryValue> result_copy(
|
| + dictionary_value_result_->DeepCopy());
|
| + callback.Run(result_copy.Pass());
|
| }
|
|
|
| // Mock NetworkOperationCallback.
|
| @@ -534,7 +550,9 @@ TEST_F(CrosNetworkFunctionsTest, CrosMonitorSMS) {
|
| base::Bind(&CrosNetworkFunctionsTest::MockMonitorSMSCallback,
|
| base::Unretained(this)));
|
| // Return GetProperties() result.
|
| - get_properties_callback.Run(DBUS_METHOD_CALL_SUCCESS, device_properties);
|
| + scoped_ptr<base::DictionaryValue> properties_copy(
|
| + device_properties.DeepCopy());
|
| + get_properties_callback.Run(DBUS_METHOD_CALL_SUCCESS, properties_copy.Pass());
|
| // Return List() result.
|
| ASSERT_FALSE(list_callback.is_null());
|
| list_callback.Run(sms_list);
|
| @@ -901,7 +919,7 @@ TEST_F(CrosNetworkFunctionsTest, CrosSetOfflineMode) {
|
| CrosSetOfflineMode(kOffline);
|
| }
|
|
|
| -TEST_F(CrosNetworkFunctionsTest, CrosListIPConfigs) {
|
| +TEST_F(CrosNetworkFunctionsTest, CrosListIPConfigsAndBlock) {
|
| const std::string device_path = "/device/path";
|
| std::string ipconfig_path = "/ipconfig/path";
|
|
|
| @@ -970,8 +988,10 @@ TEST_F(CrosNetworkFunctionsTest, CrosListIPConfigs) {
|
| std::vector<std::string> result_ipconfig_paths;
|
| std::string result_hardware_address;
|
| EXPECT_TRUE(
|
| - CrosListIPConfigs(device_path, &result_ipconfigs, &result_ipconfig_paths,
|
| - &result_hardware_address));
|
| + CrosListIPConfigsAndBlock(device_path,
|
| + &result_ipconfigs,
|
| + &result_ipconfig_paths,
|
| + &result_hardware_address));
|
|
|
| EXPECT_EQ(hardware_address, result_hardware_address);
|
| ASSERT_EQ(1U, result_ipconfigs.size());
|
|
|