| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/run_loop.h" | 6 #include "base/run_loop.h" |
| 7 #include "base/test/mock_callback.h" | 7 #include "base/test/mock_callback.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "chromeos/dbus/shill_client_unittest_base.h" | 9 #include "chromeos/dbus/shill_client_unittest_base.h" |
| 10 #include "chromeos/dbus/shill_device_client.h" | 10 #include "chromeos/dbus/shill_device_client.h" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 TEST_F(ShillDeviceClientTest, PropertyChanged) { | 76 TEST_F(ShillDeviceClientTest, PropertyChanged) { |
| 77 const bool kValue = true; | 77 const bool kValue = true; |
| 78 // Create a signal. | 78 // Create a signal. |
| 79 dbus::Signal signal(shill::kFlimflamDeviceInterface, | 79 dbus::Signal signal(shill::kFlimflamDeviceInterface, |
| 80 shill::kMonitorPropertyChanged); | 80 shill::kMonitorPropertyChanged); |
| 81 dbus::MessageWriter writer(&signal); | 81 dbus::MessageWriter writer(&signal); |
| 82 writer.AppendString(shill::kCellularAllowRoamingProperty); | 82 writer.AppendString(shill::kCellularAllowRoamingProperty); |
| 83 writer.AppendVariantOfBool(kValue); | 83 writer.AppendVariantOfBool(kValue); |
| 84 | 84 |
| 85 // Set expectations. | 85 // Set expectations. |
| 86 const base::FundamentalValue value(kValue); | 86 const base::Value value(kValue); |
| 87 MockPropertyChangeObserver observer; | 87 MockPropertyChangeObserver observer; |
| 88 EXPECT_CALL(observer, | 88 EXPECT_CALL(observer, |
| 89 OnPropertyChanged(shill::kCellularAllowRoamingProperty, | 89 OnPropertyChanged(shill::kCellularAllowRoamingProperty, |
| 90 ValueEq(ByRef(value)))).Times(1); | 90 ValueEq(ByRef(value)))).Times(1); |
| 91 | 91 |
| 92 // Add the observer | 92 // Add the observer |
| 93 client_->AddPropertyChangedObserver( | 93 client_->AddPropertyChangedObserver( |
| 94 dbus::ObjectPath(kExampleDevicePath), | 94 dbus::ObjectPath(kExampleDevicePath), |
| 95 &observer); | 95 &observer); |
| 96 | 96 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 120 dbus::MessageWriter entry_writer(NULL); | 120 dbus::MessageWriter entry_writer(NULL); |
| 121 array_writer.OpenDictEntry(&entry_writer); | 121 array_writer.OpenDictEntry(&entry_writer); |
| 122 entry_writer.AppendString(shill::kCellularAllowRoamingProperty); | 122 entry_writer.AppendString(shill::kCellularAllowRoamingProperty); |
| 123 entry_writer.AppendVariantOfBool(kValue); | 123 entry_writer.AppendVariantOfBool(kValue); |
| 124 array_writer.CloseContainer(&entry_writer); | 124 array_writer.CloseContainer(&entry_writer); |
| 125 writer.CloseContainer(&array_writer); | 125 writer.CloseContainer(&array_writer); |
| 126 | 126 |
| 127 // Set expectations. | 127 // Set expectations. |
| 128 base::DictionaryValue value; | 128 base::DictionaryValue value; |
| 129 value.SetWithoutPathExpansion(shill::kCellularAllowRoamingProperty, | 129 value.SetWithoutPathExpansion(shill::kCellularAllowRoamingProperty, |
| 130 new base::FundamentalValue(kValue)); | 130 new base::Value(kValue)); |
| 131 PrepareForMethodCall(shill::kGetPropertiesFunction, | 131 PrepareForMethodCall(shill::kGetPropertiesFunction, |
| 132 base::Bind(&ExpectNoArgument), | 132 base::Bind(&ExpectNoArgument), |
| 133 response.get()); | 133 response.get()); |
| 134 // Call method. | 134 // Call method. |
| 135 client_->GetProperties(dbus::ObjectPath(kExampleDevicePath), | 135 client_->GetProperties(dbus::ObjectPath(kExampleDevicePath), |
| 136 base::Bind(&ExpectDictionaryValueResult, &value)); | 136 base::Bind(&ExpectDictionaryValueResult, &value)); |
| 137 // Run the message loop. | 137 // Run the message loop. |
| 138 base::RunLoop().RunUntilIdle(); | 138 base::RunLoop().RunUntilIdle(); |
| 139 } | 139 } |
| 140 | 140 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 152 // Run the message loop. | 152 // Run the message loop. |
| 153 base::RunLoop().RunUntilIdle(); | 153 base::RunLoop().RunUntilIdle(); |
| 154 } | 154 } |
| 155 | 155 |
| 156 TEST_F(ShillDeviceClientTest, SetProperty) { | 156 TEST_F(ShillDeviceClientTest, SetProperty) { |
| 157 const bool kValue = true; | 157 const bool kValue = true; |
| 158 // Create response. | 158 // Create response. |
| 159 std::unique_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); | 159 std::unique_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); |
| 160 | 160 |
| 161 // Set expectations. | 161 // Set expectations. |
| 162 const base::FundamentalValue value(kValue); | 162 const base::Value value(kValue); |
| 163 PrepareForMethodCall(shill::kSetPropertyFunction, | 163 PrepareForMethodCall(shill::kSetPropertyFunction, |
| 164 base::Bind(&ExpectStringAndValueArguments, | 164 base::Bind(&ExpectStringAndValueArguments, |
| 165 shill::kCellularAllowRoamingProperty, | 165 shill::kCellularAllowRoamingProperty, |
| 166 &value), | 166 &value), |
| 167 response.get()); | 167 response.get()); |
| 168 // Call method. | 168 // Call method. |
| 169 base::MockCallback<base::Closure> mock_closure; | 169 base::MockCallback<base::Closure> mock_closure; |
| 170 base::MockCallback<ShillDeviceClient::ErrorCallback> mock_error_callback; | 170 base::MockCallback<ShillDeviceClient::ErrorCallback> mock_error_callback; |
| 171 client_->SetProperty(dbus::ObjectPath(kExampleDevicePath), | 171 client_->SetProperty(dbus::ObjectPath(kExampleDevicePath), |
| 172 shill::kCellularAllowRoamingProperty, value, | 172 shill::kCellularAllowRoamingProperty, value, |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 response.get()); | 357 response.get()); |
| 358 EXPECT_CALL(mock_closure, Run()).Times(1); | 358 EXPECT_CALL(mock_closure, Run()).Times(1); |
| 359 // Call method. | 359 // Call method. |
| 360 client_->Reset(dbus::ObjectPath(kExampleDevicePath), mock_closure.Get(), | 360 client_->Reset(dbus::ObjectPath(kExampleDevicePath), mock_closure.Get(), |
| 361 mock_error_callback.Get()); | 361 mock_error_callback.Get()); |
| 362 // Run the message loop. | 362 // Run the message loop. |
| 363 base::RunLoop().RunUntilIdle(); | 363 base::RunLoop().RunUntilIdle(); |
| 364 } | 364 } |
| 365 | 365 |
| 366 } // namespace chromeos | 366 } // namespace chromeos |
| OLD | NEW |