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

Side by Side Diff: chromeos/network/shill_property_handler_unittest.cc

Issue 14813021: Observe property updates for all Network Services (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 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 "chromeos/network/shill_property_handler.h" 5 #include "chromeos/network/shill_property_handler.h"
6 6
7 #include <map> 7 #include <map>
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 10
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 const size_t kNumShillManagerClientStubImplServices = 4; 317 const size_t kNumShillManagerClientStubImplServices = 4;
318 EXPECT_EQ(kNumShillManagerClientStubImplServices, 318 EXPECT_EQ(kNumShillManagerClientStubImplServices,
319 listener_->entries(flimflam::kServicesProperty).size()); 319 listener_->entries(flimflam::kServicesProperty).size());
320 320
321 // Add an unwatched service. 321 // Add an unwatched service.
322 const std::string kTestServicePath("test_wifi_service1"); 322 const std::string kTestServicePath("test_wifi_service1");
323 AddService(flimflam::kTypeWifi, kTestServicePath, 323 AddService(flimflam::kTypeWifi, kTestServicePath,
324 flimflam::kStateIdle, false); 324 flimflam::kStateIdle, false);
325 message_loop_.RunUntilIdle(); 325 message_loop_.RunUntilIdle();
326 EXPECT_EQ(1, listener_->manager_updates()); // No new manager updates. 326 EXPECT_EQ(1, listener_->manager_updates()); // No new manager updates.
327 // Only watched services trigger a service list update. 327 // Watched and unwatched services trigger a service list update.
328 EXPECT_EQ(1, listener_->list_updates(flimflam::kServicesProperty)); 328 EXPECT_EQ(2, listener_->list_updates(flimflam::kServicesProperty));
329 EXPECT_EQ(kNumShillManagerClientStubImplServices + 1, 329 EXPECT_EQ(kNumShillManagerClientStubImplServices + 1,
330 listener_->entries(flimflam::kServicesProperty).size()); 330 listener_->entries(flimflam::kServicesProperty).size());
331 // Service receives an initial property update.
332 EXPECT_EQ(1, listener_->
333 property_updates(flimflam::kServicesProperty)[kTestServicePath]);
331 // Change a property. 334 // Change a property.
332 base::FundamentalValue scan_interval(3); 335 base::FundamentalValue scan_interval(3);
333 DBusThreadManager::Get()->GetShillServiceClient()->SetProperty( 336 DBusThreadManager::Get()->GetShillServiceClient()->SetProperty(
334 dbus::ObjectPath(kTestServicePath), 337 dbus::ObjectPath(kTestServicePath),
335 flimflam::kScanIntervalProperty, 338 flimflam::kScanIntervalProperty,
336 scan_interval, 339 scan_interval,
337 base::Bind(&base::DoNothing), base::Bind(&ErrorCallbackFunction)); 340 base::Bind(&base::DoNothing), base::Bind(&ErrorCallbackFunction));
338 message_loop_.RunUntilIdle(); 341 message_loop_.RunUntilIdle();
339 // Property change should NOT trigger an update. 342 // Property change triggers an update.
340 EXPECT_EQ(0, listener_-> 343 EXPECT_EQ(2, listener_->
341 property_updates(flimflam::kServicesProperty)[kTestServicePath]); 344 property_updates(flimflam::kServicesProperty)[kTestServicePath]);
342 345
343 // Add the existing service to the watch list. 346 // Add the existing service to the watch list.
344 AddService(flimflam::kTypeWifi, kTestServicePath, 347 AddService(flimflam::kTypeWifi, kTestServicePath,
345 flimflam::kStateIdle, true); 348 flimflam::kStateIdle, true);
346 message_loop_.RunUntilIdle(); 349 message_loop_.RunUntilIdle();
347 // Service list update should be received when watch list changes. 350 // Service list update should be received when watch list changes.
348 EXPECT_EQ(2, listener_->list_updates(flimflam::kServicesProperty)); 351 EXPECT_EQ(2, listener_->list_updates(flimflam::kServicesProperty));
349 // Number of services shouldn't change. 352 // Number of services shouldn't change.
350 EXPECT_EQ(kNumShillManagerClientStubImplServices + 1, 353 EXPECT_EQ(kNumShillManagerClientStubImplServices + 1,
351 listener_->entries(flimflam::kServicesProperty).size()); 354 listener_->entries(flimflam::kServicesProperty).size());
352 // Property update should be received when watched service is added.
353 EXPECT_EQ(1, listener_->
354 property_updates(flimflam::kServicesProperty)[kTestServicePath]);
355 355
356 // Change a property. 356 // Change a property.
357 DBusThreadManager::Get()->GetShillServiceClient()->SetProperty( 357 DBusThreadManager::Get()->GetShillServiceClient()->SetProperty(
358 dbus::ObjectPath(kTestServicePath), 358 dbus::ObjectPath(kTestServicePath),
359 flimflam::kScanIntervalProperty, 359 flimflam::kScanIntervalProperty,
360 scan_interval, 360 scan_interval,
361 base::Bind(&base::DoNothing), base::Bind(&ErrorCallbackFunction)); 361 base::Bind(&base::DoNothing), base::Bind(&ErrorCallbackFunction));
362 message_loop_.RunUntilIdle(); 362 message_loop_.RunUntilIdle();
363 // Property change should trigger another update. 363 // Property change should trigger another update.
364 EXPECT_EQ(2, listener_-> 364 EXPECT_EQ(3, listener_->
365 property_updates(flimflam::kServicesProperty)[kTestServicePath]); 365 property_updates(flimflam::kServicesProperty)[kTestServicePath]);
366 366
367 // Remove a service 367 // Remove a service
368 RemoveService(kTestServicePath); 368 RemoveService(kTestServicePath);
369 message_loop_.RunUntilIdle(); 369 message_loop_.RunUntilIdle();
370 EXPECT_EQ(3, listener_->list_updates(flimflam::kServicesProperty)); 370 EXPECT_EQ(3, listener_->list_updates(flimflam::kServicesProperty));
371 EXPECT_EQ(kNumShillManagerClientStubImplServices, 371 EXPECT_EQ(kNumShillManagerClientStubImplServices,
372 listener_->entries(flimflam::kServicesProperty).size()); 372 listener_->entries(flimflam::kServicesProperty).size());
373 373
374 EXPECT_EQ(0, listener_->errors()); 374 EXPECT_EQ(0, listener_->errors());
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 AddServiceWithIPConfig(flimflam::kTypeWifi, kTestServicePath2, 418 AddServiceWithIPConfig(flimflam::kTypeWifi, kTestServicePath2,
419 flimflam::kStateIdle, kTestIPConfigPath, true); 419 flimflam::kStateIdle, kTestIPConfigPath, true);
420 message_loop_.RunUntilIdle(); 420 message_loop_.RunUntilIdle();
421 // A watched service with the IPConfig property already set must 421 // A watched service with the IPConfig property already set must
422 // trigger property updates for IP Address and DNS when added. 422 // trigger property updates for IP Address and DNS when added.
423 EXPECT_EQ(3, listener_-> 423 EXPECT_EQ(3, listener_->
424 property_updates(flimflam::kServicesProperty)[kTestServicePath2]); 424 property_updates(flimflam::kServicesProperty)[kTestServicePath2]);
425 } 425 }
426 426
427 } // namespace chromeos 427 } // namespace chromeos
OLDNEW
« chromeos/network/shill_property_handler.cc ('K') | « chromeos/network/shill_property_handler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698