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/values.h" | 6 #include "base/values.h" |
7 #include "chromeos/dbus/shill_client_unittest_base.h" | 7 #include "chromeos/dbus/shill_client_unittest_base.h" |
8 #include "chromeos/dbus/shill_service_client.h" | 8 #include "chromeos/dbus/shill_service_client.h" |
9 #include "dbus/message.h" | 9 #include "dbus/message.h" |
10 #include "dbus/object_path.h" | 10 #include "dbus/object_path.h" |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); | 117 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); |
118 | 118 |
119 // Set expectations. | 119 // Set expectations. |
120 const base::StringValue value(kValue); | 120 const base::StringValue value(kValue); |
121 PrepareForMethodCall(flimflam::kSetPropertyFunction, | 121 PrepareForMethodCall(flimflam::kSetPropertyFunction, |
122 base::Bind(&ExpectStringAndValueArguments, | 122 base::Bind(&ExpectStringAndValueArguments, |
123 flimflam::kPassphraseProperty, | 123 flimflam::kPassphraseProperty, |
124 &value), | 124 &value), |
125 response.get()); | 125 response.get()); |
126 // Call method. | 126 // Call method. |
| 127 MockClosure mock_closure; |
| 128 MockErrorCallback mock_error_callback; |
127 client_->SetProperty(dbus::ObjectPath(kExampleServicePath), | 129 client_->SetProperty(dbus::ObjectPath(kExampleServicePath), |
128 flimflam::kPassphraseProperty, | 130 flimflam::kPassphraseProperty, |
129 value, | 131 value, |
130 base::Bind(&ExpectNoResultValue)); | 132 mock_closure.GetCallback(), |
| 133 mock_error_callback.GetCallback()); |
| 134 EXPECT_CALL(mock_closure, Run()).Times(1); |
| 135 EXPECT_CALL(mock_error_callback, Run(_, _)).Times(0); |
| 136 |
131 // Run the message loop. | 137 // Run the message loop. |
132 message_loop_.RunAllPending(); | 138 message_loop_.RunAllPending(); |
133 } | 139 } |
134 | 140 |
135 TEST_F(ShillServiceClientTest, ClearProperty) { | 141 TEST_F(ShillServiceClientTest, ClearProperty) { |
136 // Create response. | 142 // Create response. |
137 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); | 143 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); |
138 | 144 |
139 // Set expectations. | 145 // Set expectations. |
140 PrepareForMethodCall(flimflam::kClearPropertyFunction, | 146 PrepareForMethodCall(flimflam::kClearPropertyFunction, |
141 base::Bind(&ExpectStringArgument, | 147 base::Bind(&ExpectStringArgument, |
142 flimflam::kPassphraseProperty), | 148 flimflam::kPassphraseProperty), |
143 response.get()); | 149 response.get()); |
144 // Call method. | 150 // Call method. |
| 151 MockClosure mock_closure; |
| 152 MockErrorCallback mock_error_callback; |
145 client_->ClearProperty(dbus::ObjectPath(kExampleServicePath), | 153 client_->ClearProperty(dbus::ObjectPath(kExampleServicePath), |
146 flimflam::kPassphraseProperty, | 154 flimflam::kPassphraseProperty, |
147 base::Bind(&ExpectNoResultValue)); | 155 mock_closure.GetCallback(), |
| 156 mock_error_callback.GetCallback()); |
| 157 EXPECT_CALL(mock_closure, Run()).Times(1); |
| 158 EXPECT_CALL(mock_error_callback, Run(_, _)).Times(0); |
| 159 |
148 // Run the message loop. | 160 // Run the message loop. |
149 message_loop_.RunAllPending(); | 161 message_loop_.RunAllPending(); |
150 } | 162 } |
151 | 163 |
152 TEST_F(ShillServiceClientTest, Connect) { | 164 TEST_F(ShillServiceClientTest, Connect) { |
153 // Create response. | 165 // Create response. |
154 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); | 166 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); |
155 | 167 |
156 // Set expectations. | 168 // Set expectations. |
157 MockClosure mock_closure; | 169 MockClosure mock_closure; |
(...skipping 13 matching lines...) Expand all Loading... |
171 | 183 |
172 TEST_F(ShillServiceClientTest, Disconnect) { | 184 TEST_F(ShillServiceClientTest, Disconnect) { |
173 // Create response. | 185 // Create response. |
174 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); | 186 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); |
175 | 187 |
176 // Set expectations. | 188 // Set expectations. |
177 PrepareForMethodCall(flimflam::kDisconnectFunction, | 189 PrepareForMethodCall(flimflam::kDisconnectFunction, |
178 base::Bind(&ExpectNoArgument), | 190 base::Bind(&ExpectNoArgument), |
179 response.get()); | 191 response.get()); |
180 // Call method. | 192 // Call method. |
| 193 MockClosure mock_closure; |
| 194 MockErrorCallback mock_error_callback; |
181 client_->Disconnect(dbus::ObjectPath(kExampleServicePath), | 195 client_->Disconnect(dbus::ObjectPath(kExampleServicePath), |
182 base::Bind(&ExpectNoResultValue)); | 196 mock_closure.GetCallback(), |
| 197 mock_error_callback.GetCallback()); |
| 198 EXPECT_CALL(mock_closure, Run()).Times(1); |
| 199 EXPECT_CALL(mock_error_callback, Run(_, _)).Times(0); |
| 200 |
183 // Run the message loop. | 201 // Run the message loop. |
184 message_loop_.RunAllPending(); | 202 message_loop_.RunAllPending(); |
185 } | 203 } |
186 | 204 |
187 TEST_F(ShillServiceClientTest, Remove) { | 205 TEST_F(ShillServiceClientTest, Remove) { |
188 // Create response. | 206 // Create response. |
189 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); | 207 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); |
190 | 208 |
191 // Set expectations. | 209 // Set expectations. |
192 PrepareForMethodCall(flimflam::kRemoveServiceFunction, | 210 PrepareForMethodCall(flimflam::kRemoveServiceFunction, |
193 base::Bind(&ExpectNoArgument), | 211 base::Bind(&ExpectNoArgument), |
194 response.get()); | 212 response.get()); |
195 // Call method. | 213 // Call method. |
| 214 MockClosure mock_closure; |
| 215 MockErrorCallback mock_error_callback; |
196 client_->Remove(dbus::ObjectPath(kExampleServicePath), | 216 client_->Remove(dbus::ObjectPath(kExampleServicePath), |
197 base::Bind(&ExpectNoResultValue)); | 217 mock_closure.GetCallback(), |
| 218 mock_error_callback.GetCallback()); |
| 219 EXPECT_CALL(mock_closure, Run()).Times(1); |
| 220 EXPECT_CALL(mock_error_callback, Run(_, _)).Times(0); |
| 221 |
198 // Run the message loop. | 222 // Run the message loop. |
199 message_loop_.RunAllPending(); | 223 message_loop_.RunAllPending(); |
200 } | 224 } |
201 | 225 |
202 TEST_F(ShillServiceClientTest, ActivateCellularModem) { | 226 TEST_F(ShillServiceClientTest, ActivateCellularModem) { |
203 const char kCarrier[] = "carrier"; | 227 const char kCarrier[] = "carrier"; |
204 // Create response. | 228 // Create response. |
205 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); | 229 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); |
206 | 230 |
207 // Set expectations. | 231 // Set expectations. |
208 PrepareForMethodCall(flimflam::kActivateCellularModemFunction, | 232 PrepareForMethodCall(flimflam::kActivateCellularModemFunction, |
209 base::Bind(&ExpectStringArgument, kCarrier), | 233 base::Bind(&ExpectStringArgument, kCarrier), |
210 response.get()); | 234 response.get()); |
211 // Call method. | 235 // Call method. |
| 236 MockClosure mock_closure; |
| 237 MockErrorCallback mock_error_callback; |
212 client_->ActivateCellularModem(dbus::ObjectPath(kExampleServicePath), | 238 client_->ActivateCellularModem(dbus::ObjectPath(kExampleServicePath), |
213 kCarrier, | 239 kCarrier, |
214 base::Bind(&ExpectNoResultValue)); | 240 mock_closure.GetCallback(), |
| 241 mock_error_callback.GetCallback()); |
| 242 EXPECT_CALL(mock_closure, Run()).Times(1); |
| 243 EXPECT_CALL(mock_error_callback, Run(_, _)).Times(0); |
| 244 |
215 // Run the message loop. | 245 // Run the message loop. |
216 message_loop_.RunAllPending(); | 246 message_loop_.RunAllPending(); |
217 } | 247 } |
218 | 248 |
219 TEST_F(ShillServiceClientTest, CallActivateCellularModemAndBlock) { | 249 TEST_F(ShillServiceClientTest, CallActivateCellularModemAndBlock) { |
220 const char kCarrier[] = "carrier"; | 250 const char kCarrier[] = "carrier"; |
221 // Create response. | 251 // Create response. |
222 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); | 252 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); |
223 | 253 |
224 // Set expectations. | 254 // Set expectations. |
225 PrepareForMethodCall(flimflam::kActivateCellularModemFunction, | 255 PrepareForMethodCall(flimflam::kActivateCellularModemFunction, |
226 base::Bind(&ExpectStringArgument, kCarrier), | 256 base::Bind(&ExpectStringArgument, kCarrier), |
227 response.get()); | 257 response.get()); |
228 // Call method. | 258 // Call method. |
229 const bool result = client_->CallActivateCellularModemAndBlock( | 259 const bool result = client_->CallActivateCellularModemAndBlock( |
230 dbus::ObjectPath(kExampleServicePath), kCarrier); | 260 dbus::ObjectPath(kExampleServicePath), kCarrier); |
231 EXPECT_TRUE(result); | 261 EXPECT_TRUE(result); |
232 } | 262 } |
233 | 263 |
234 } // namespace chromeos | 264 } // namespace chromeos |
OLD | NEW |