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

Side by Side Diff: chromeos/dbus/shill_manager_client_unittest.cc

Issue 11887008: Deprecate ShillNetworkClient and add GeolocationHandler (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix unittest Created 7 years, 11 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 | Annotate | Revision Log
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/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_manager_client.h" 8 #include "chromeos/dbus/shill_manager_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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 // Set expectations. 203 // Set expectations.
204 PrepareForMethodCall(flimflam::kGetPropertiesFunction, 204 PrepareForMethodCall(flimflam::kGetPropertiesFunction,
205 base::Bind(&ExpectNoArgument), 205 base::Bind(&ExpectNoArgument),
206 response.get()); 206 response.get());
207 // Call method. 207 // Call method.
208 scoped_ptr<base::DictionaryValue> result( 208 scoped_ptr<base::DictionaryValue> result(
209 client_->CallGetPropertiesAndBlock()); 209 client_->CallGetPropertiesAndBlock());
210 EXPECT_TRUE(value.Equals(result.get())); 210 EXPECT_TRUE(value.Equals(result.get()));
211 } 211 }
212 212
213 TEST_F(ShillManagerClientTest, GetNetworksForGeolocation) {
214 // Create response.
215 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty());
216
217 dbus::MessageWriter writer(response.get());
218 dbus::MessageWriter type_dict_writer(NULL);
219 writer.OpenArray("{sv}", &type_dict_writer);
220 dbus::MessageWriter type_entry_writer(NULL);
221 type_dict_writer.OpenDictEntry(&type_entry_writer);
222 type_entry_writer.AppendString(flimflam::kTypeWifi);
223 dbus::MessageWriter variant_writer(NULL);
224 type_entry_writer.OpenVariant("aa{ss}", &variant_writer);
225 dbus::MessageWriter wap_list_writer(NULL);
226 variant_writer.OpenArray("a{ss}", &wap_list_writer);
227 dbus::MessageWriter property_dict_writer(NULL);
228 wap_list_writer.OpenArray("{ss}", &property_dict_writer);
229 dbus::MessageWriter property_entry_writer(NULL);
230 property_dict_writer.OpenDictEntry(&property_entry_writer);
231 property_entry_writer.AppendString(shill::kGeoMacAddressProperty);
232 property_entry_writer.AppendString("01:23:45:67:89:AB");
233 property_dict_writer.CloseContainer(&property_entry_writer);
234 wap_list_writer.CloseContainer(&property_dict_writer);
235 variant_writer.CloseContainer(&wap_list_writer);
236 type_entry_writer.CloseContainer(&wap_list_writer);
237 type_dict_writer.CloseContainer(&type_entry_writer);
238 writer.CloseContainer(&type_dict_writer);
239
240
241 // Create the expected value.
242 base::DictionaryValue type_dict_value;
243 base::ListValue* type_entry_value = new base::ListValue;
244 base::DictionaryValue* property_dict_value = new base::DictionaryValue;
245 property_dict_value->SetWithoutPathExpansion(
246 shill::kGeoMacAddressProperty,
247 base::Value::CreateStringValue("01:23:45:67:89:AB"));
248 type_entry_value->Append(property_dict_value);
249 type_dict_value.SetWithoutPathExpansion("wifi", type_entry_value);
250
251 // Set expectations.
252 PrepareForMethodCall(shill::kGetNetworksForGeolocation,
253 base::Bind(&ExpectNoArgument),
254 response.get());
255 // Call method.
256 client_->GetNetworksForGeolocation(base::Bind(&ExpectDictionaryValueResult,
257 &type_dict_value));
258
259 // Run the message loop.
260 message_loop_.RunUntilIdle();
261 }
262
213 TEST_F(ShillManagerClientTest, SetProperty) { 263 TEST_F(ShillManagerClientTest, SetProperty) {
214 // Create response. 264 // Create response.
215 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); 265 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty());
216 // Set expectations. 266 // Set expectations.
217 base::StringValue value("portal list"); 267 base::StringValue value("portal list");
218 PrepareForMethodCall(flimflam::kSetPropertyFunction, 268 PrepareForMethodCall(flimflam::kSetPropertyFunction,
219 base::Bind(ExpectStringAndValueArguments, 269 base::Bind(ExpectStringAndValueArguments,
220 flimflam::kCheckPortalListProperty, 270 flimflam::kCheckPortalListProperty,
221 &value), 271 &value),
222 response.get()); 272 response.get());
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 base::Bind(&ExpectObjectPathResultWithoutStatus, 384 base::Bind(&ExpectObjectPathResultWithoutStatus,
335 object_path), 385 object_path),
336 mock_error_callback.GetCallback()); 386 mock_error_callback.GetCallback());
337 EXPECT_CALL(mock_error_callback, Run(_, _)).Times(0); 387 EXPECT_CALL(mock_error_callback, Run(_, _)).Times(0);
338 388
339 // Run the message loop. 389 // Run the message loop.
340 message_loop_.RunUntilIdle(); 390 message_loop_.RunUntilIdle();
341 } 391 }
342 392
343 } // namespace chromeos 393 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698