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