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

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

Issue 2314853004: Remove calls to deprecated MessageLoop methods in chromeos. (Closed)
Patch Set: Created 4 years, 3 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 <iostream> 5 #include <iostream>
6 #include <memory> 6 #include <memory>
7 #include <sstream> 7 #include <sstream>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
11 #include "base/location.h" 11 #include "base/location.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/message_loop/message_loop.h" 13 #include "base/message_loop/message_loop.h"
14 #include "base/run_loop.h"
14 #include "base/single_thread_task_runner.h" 15 #include "base/single_thread_task_runner.h"
15 #include "base/stl_util.h" 16 #include "base/stl_util.h"
16 #include "base/threading/thread_task_runner_handle.h" 17 #include "base/threading/thread_task_runner_handle.h"
17 #include "base/values.h" 18 #include "base/values.h"
18 #include "chromeos/dbus/dbus_thread_manager.h" 19 #include "chromeos/dbus/dbus_thread_manager.h"
19 #include "chromeos/dbus/mock_shill_manager_client.h" 20 #include "chromeos/dbus/mock_shill_manager_client.h"
20 #include "chromeos/dbus/mock_shill_profile_client.h" 21 #include "chromeos/dbus/mock_shill_profile_client.h"
21 #include "chromeos/dbus/mock_shill_service_client.h" 22 #include "chromeos/dbus/mock_shill_service_client.h"
22 #include "chromeos/dbus/shill_client_helper.h" 23 #include "chromeos/dbus/shill_client_helper.h"
23 #include "chromeos/network/managed_network_configuration_handler_impl.h" 24 #include "chromeos/network/managed_network_configuration_handler_impl.h"
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 network_state_handler_.get(), 264 network_state_handler_.get(),
264 nullptr /* no NetworkDeviceHandler */)); 265 nullptr /* no NetworkDeviceHandler */));
265 managed_network_configuration_handler_.reset( 266 managed_network_configuration_handler_.reset(
266 new ManagedNetworkConfigurationHandlerImpl()); 267 new ManagedNetworkConfigurationHandlerImpl());
267 managed_network_configuration_handler_->Init( 268 managed_network_configuration_handler_->Init(
268 network_state_handler_.get(), network_profile_handler_.get(), 269 network_state_handler_.get(), network_profile_handler_.get(),
269 network_configuration_handler_.get(), nullptr /* no DeviceHandler */, 270 network_configuration_handler_.get(), nullptr /* no DeviceHandler */,
270 nullptr /* no ProhibitedTechnologiesHandler */); 271 nullptr /* no ProhibitedTechnologiesHandler */);
271 managed_network_configuration_handler_->AddObserver(&policy_observer_); 272 managed_network_configuration_handler_->AddObserver(&policy_observer_);
272 273
273 message_loop_.RunUntilIdle(); 274 base::RunLoop().RunUntilIdle();
274 } 275 }
275 276
276 void TearDown() override { 277 void TearDown() override {
277 if (managed_network_configuration_handler_) 278 if (managed_network_configuration_handler_)
278 managed_network_configuration_handler_->RemoveObserver(&policy_observer_); 279 managed_network_configuration_handler_->RemoveObserver(&policy_observer_);
279 network_state_handler_.reset(); 280 network_state_handler_.reset();
280 managed_network_configuration_handler_.reset(); 281 managed_network_configuration_handler_.reset();
281 network_configuration_handler_.reset(); 282 network_configuration_handler_.reset();
282 network_profile_handler_.reset(); 283 network_profile_handler_.reset();
283 DBusThreadManager::Shutdown(); 284 DBusThreadManager::Shutdown();
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 MockShillProfileClient* mock_profile_client_; 379 MockShillProfileClient* mock_profile_client_;
379 MockShillServiceClient* mock_service_client_; 380 MockShillServiceClient* mock_service_client_;
380 ShillProfileTestClient profiles_stub_; 381 ShillProfileTestClient profiles_stub_;
381 ShillServiceTestClient services_stub_; 382 ShillServiceTestClient services_stub_;
382 TestNetworkPolicyObserver policy_observer_; 383 TestNetworkPolicyObserver policy_observer_;
383 std::unique_ptr<NetworkStateHandler> network_state_handler_; 384 std::unique_ptr<NetworkStateHandler> network_state_handler_;
384 std::unique_ptr<TestNetworkProfileHandler> network_profile_handler_; 385 std::unique_ptr<TestNetworkProfileHandler> network_profile_handler_;
385 std::unique_ptr<NetworkConfigurationHandler> network_configuration_handler_; 386 std::unique_ptr<NetworkConfigurationHandler> network_configuration_handler_;
386 std::unique_ptr<ManagedNetworkConfigurationHandlerImpl> 387 std::unique_ptr<ManagedNetworkConfigurationHandlerImpl>
387 managed_network_configuration_handler_; 388 managed_network_configuration_handler_;
388 base::MessageLoop message_loop_; 389 base::MessageLoop message_loop_;
armansito 2016/09/06 22:04:32 Is this still needed? It doesn't seem to get used.
fdoray 2016/09/07 13:03:48 ditto
389 390
390 std::string get_properties_service_path_; 391 std::string get_properties_service_path_;
391 base::DictionaryValue get_properties_result_; 392 base::DictionaryValue get_properties_result_;
392 393
393 private: 394 private:
394 DISALLOW_COPY_AND_ASSIGN(ManagedNetworkConfigurationHandlerTest); 395 DISALLOW_COPY_AND_ASSIGN(ManagedNetworkConfigurationHandlerTest);
395 }; 396 };
396 397
397 TEST_F(ManagedNetworkConfigurationHandlerTest, ProfileInitialization) { 398 TEST_F(ManagedNetworkConfigurationHandlerTest, ProfileInitialization) {
398 InitializeStandardProfiles(); 399 InitializeStandardProfiles();
399 message_loop_.RunUntilIdle(); 400 base::RunLoop().RunUntilIdle();
400 } 401 }
401 402
402 TEST_F(ManagedNetworkConfigurationHandlerTest, RemoveIrrelevantFields) { 403 TEST_F(ManagedNetworkConfigurationHandlerTest, RemoveIrrelevantFields) {
403 InitializeStandardProfiles(); 404 InitializeStandardProfiles();
404 std::unique_ptr<base::DictionaryValue> expected_shill_properties = 405 std::unique_ptr<base::DictionaryValue> expected_shill_properties =
405 test_utils::ReadTestDictionary( 406 test_utils::ReadTestDictionary(
406 "policy/shill_policy_on_unconfigured_wifi1.json"); 407 "policy/shill_policy_on_unconfigured_wifi1.json");
407 408
408 EXPECT_CALL(*mock_profile_client_, 409 EXPECT_CALL(*mock_profile_client_,
409 GetProperties(dbus::ObjectPath(kUser1ProfilePath), _, _)); 410 GetProperties(dbus::ObjectPath(kUser1ProfilePath), _, _));
410 411
411 EXPECT_CALL(*mock_manager_client_, 412 EXPECT_CALL(*mock_manager_client_,
412 ConfigureServiceForProfile( 413 ConfigureServiceForProfile(
413 dbus::ObjectPath(kUser1ProfilePath), 414 dbus::ObjectPath(kUser1ProfilePath),
414 IsEqualTo(expected_shill_properties.get()), 415 IsEqualTo(expected_shill_properties.get()),
415 _, _)); 416 _, _));
416 417
417 SetPolicy(::onc::ONC_SOURCE_USER_POLICY, 418 SetPolicy(::onc::ONC_SOURCE_USER_POLICY,
418 kUser1, 419 kUser1,
419 "policy/policy_wifi1_with_redundant_fields.onc"); 420 "policy/policy_wifi1_with_redundant_fields.onc");
420 message_loop_.RunUntilIdle(); 421 base::RunLoop().RunUntilIdle();
421 } 422 }
422 423
423 TEST_F(ManagedNetworkConfigurationHandlerTest, SetPolicyManageUnconfigured) { 424 TEST_F(ManagedNetworkConfigurationHandlerTest, SetPolicyManageUnconfigured) {
424 InitializeStandardProfiles(); 425 InitializeStandardProfiles();
425 std::unique_ptr<base::DictionaryValue> expected_shill_properties = 426 std::unique_ptr<base::DictionaryValue> expected_shill_properties =
426 test_utils::ReadTestDictionary( 427 test_utils::ReadTestDictionary(
427 "policy/shill_policy_on_unconfigured_wifi1.json"); 428 "policy/shill_policy_on_unconfigured_wifi1.json");
428 429
429 EXPECT_CALL(*mock_profile_client_, 430 EXPECT_CALL(*mock_profile_client_,
430 GetProperties(dbus::ObjectPath(kUser1ProfilePath), _, _)); 431 GetProperties(dbus::ObjectPath(kUser1ProfilePath), _, _));
431 432
432 EXPECT_CALL(*mock_manager_client_, 433 EXPECT_CALL(*mock_manager_client_,
433 ConfigureServiceForProfile( 434 ConfigureServiceForProfile(
434 dbus::ObjectPath(kUser1ProfilePath), 435 dbus::ObjectPath(kUser1ProfilePath),
435 IsEqualTo(expected_shill_properties.get()), 436 IsEqualTo(expected_shill_properties.get()),
436 _, _)); 437 _, _));
437 438
438 SetPolicy(::onc::ONC_SOURCE_USER_POLICY, kUser1, "policy/policy_wifi1.onc"); 439 SetPolicy(::onc::ONC_SOURCE_USER_POLICY, kUser1, "policy/policy_wifi1.onc");
439 message_loop_.RunUntilIdle(); 440 base::RunLoop().RunUntilIdle();
440 } 441 }
441 442
442 TEST_F(ManagedNetworkConfigurationHandlerTest, EnableManagedCredentialsWiFi) { 443 TEST_F(ManagedNetworkConfigurationHandlerTest, EnableManagedCredentialsWiFi) {
443 InitializeStandardProfiles(); 444 InitializeStandardProfiles();
444 std::unique_ptr<base::DictionaryValue> expected_shill_properties = 445 std::unique_ptr<base::DictionaryValue> expected_shill_properties =
445 test_utils::ReadTestDictionary( 446 test_utils::ReadTestDictionary(
446 "policy/shill_policy_autoconnect_on_unconfigured_wifi1.json"); 447 "policy/shill_policy_autoconnect_on_unconfigured_wifi1.json");
447 448
448 EXPECT_CALL(*mock_profile_client_, 449 EXPECT_CALL(*mock_profile_client_,
449 GetProperties(dbus::ObjectPath(kUser1ProfilePath), _, _)); 450 GetProperties(dbus::ObjectPath(kUser1ProfilePath), _, _));
450 451
451 EXPECT_CALL(*mock_manager_client_, 452 EXPECT_CALL(*mock_manager_client_,
452 ConfigureServiceForProfile( 453 ConfigureServiceForProfile(
453 dbus::ObjectPath(kUser1ProfilePath), 454 dbus::ObjectPath(kUser1ProfilePath),
454 IsEqualTo(expected_shill_properties.get()), 455 IsEqualTo(expected_shill_properties.get()),
455 _, _)); 456 _, _));
456 457
457 SetPolicy(::onc::ONC_SOURCE_USER_POLICY, kUser1, 458 SetPolicy(::onc::ONC_SOURCE_USER_POLICY, kUser1,
458 "policy/policy_wifi1_autoconnect.onc"); 459 "policy/policy_wifi1_autoconnect.onc");
459 message_loop_.RunUntilIdle(); 460 base::RunLoop().RunUntilIdle();
460 } 461 }
461 462
462 TEST_F(ManagedNetworkConfigurationHandlerTest, EnableManagedCredentialsVPN) { 463 TEST_F(ManagedNetworkConfigurationHandlerTest, EnableManagedCredentialsVPN) {
463 InitializeStandardProfiles(); 464 InitializeStandardProfiles();
464 std::unique_ptr<base::DictionaryValue> expected_shill_properties = 465 std::unique_ptr<base::DictionaryValue> expected_shill_properties =
465 test_utils::ReadTestDictionary( 466 test_utils::ReadTestDictionary(
466 "policy/shill_policy_autoconnect_on_unconfigured_vpn.json"); 467 "policy/shill_policy_autoconnect_on_unconfigured_vpn.json");
467 468
468 EXPECT_CALL(*mock_profile_client_, 469 EXPECT_CALL(*mock_profile_client_,
469 GetProperties(dbus::ObjectPath(kUser1ProfilePath), _, _)); 470 GetProperties(dbus::ObjectPath(kUser1ProfilePath), _, _));
470 471
471 EXPECT_CALL(*mock_manager_client_, 472 EXPECT_CALL(*mock_manager_client_,
472 ConfigureServiceForProfile( 473 ConfigureServiceForProfile(
473 dbus::ObjectPath(kUser1ProfilePath), 474 dbus::ObjectPath(kUser1ProfilePath),
474 IsEqualTo(expected_shill_properties.get()), 475 IsEqualTo(expected_shill_properties.get()),
475 _, _)); 476 _, _));
476 477
477 SetPolicy(::onc::ONC_SOURCE_USER_POLICY, kUser1, 478 SetPolicy(::onc::ONC_SOURCE_USER_POLICY, kUser1,
478 "policy/policy_vpn_autoconnect.onc"); 479 "policy/policy_vpn_autoconnect.onc");
479 message_loop_.RunUntilIdle(); 480 base::RunLoop().RunUntilIdle();
480 } 481 }
481 482
482 // Ensure that EAP settings for ethernet are matched with the right profile 483 // Ensure that EAP settings for ethernet are matched with the right profile
483 // entry and written to the dedicated EthernetEAP service. 484 // entry and written to the dedicated EthernetEAP service.
484 TEST_F(ManagedNetworkConfigurationHandlerTest, 485 TEST_F(ManagedNetworkConfigurationHandlerTest,
485 SetPolicyManageUnmanagedEthernetEAP) { 486 SetPolicyManageUnmanagedEthernetEAP) {
486 InitializeStandardProfiles(); 487 InitializeStandardProfiles();
487 std::unique_ptr<base::DictionaryValue> expected_shill_properties = 488 std::unique_ptr<base::DictionaryValue> expected_shill_properties =
488 test_utils::ReadTestDictionary( 489 test_utils::ReadTestDictionary(
489 "policy/" 490 "policy/"
(...skipping 20 matching lines...) Expand all
510 DeleteEntry(dbus::ObjectPath(kUser1ProfilePath), "eth_entry", _, _)); 511 DeleteEntry(dbus::ObjectPath(kUser1ProfilePath), "eth_entry", _, _));
511 512
512 EXPECT_CALL( 513 EXPECT_CALL(
513 *mock_manager_client_, 514 *mock_manager_client_,
514 ConfigureServiceForProfile(dbus::ObjectPath(kUser1ProfilePath), 515 ConfigureServiceForProfile(dbus::ObjectPath(kUser1ProfilePath),
515 IsEqualTo(expected_shill_properties.get()), 516 IsEqualTo(expected_shill_properties.get()),
516 _, _)); 517 _, _));
517 518
518 SetPolicy( 519 SetPolicy(
519 ::onc::ONC_SOURCE_USER_POLICY, kUser1, "policy/policy_ethernet_eap.onc"); 520 ::onc::ONC_SOURCE_USER_POLICY, kUser1, "policy/policy_ethernet_eap.onc");
520 message_loop_.RunUntilIdle(); 521 base::RunLoop().RunUntilIdle();
521 } 522 }
522 523
523 TEST_F(ManagedNetworkConfigurationHandlerTest, SetPolicyIgnoreUnmodified) { 524 TEST_F(ManagedNetworkConfigurationHandlerTest, SetPolicyIgnoreUnmodified) {
524 InitializeStandardProfiles(); 525 InitializeStandardProfiles();
525 EXPECT_CALL(*mock_profile_client_, GetProperties(_, _, _)); 526 EXPECT_CALL(*mock_profile_client_, GetProperties(_, _, _));
526 527
527 EXPECT_CALL(*mock_manager_client_, ConfigureServiceForProfile(_, _, _, _)); 528 EXPECT_CALL(*mock_manager_client_, ConfigureServiceForProfile(_, _, _, _));
528 529
529 SetPolicy(::onc::ONC_SOURCE_USER_POLICY, kUser1, "policy/policy_wifi1.onc"); 530 SetPolicy(::onc::ONC_SOURCE_USER_POLICY, kUser1, "policy/policy_wifi1.onc");
530 message_loop_.RunUntilIdle(); 531 base::RunLoop().RunUntilIdle();
531 EXPECT_EQ(1, policy_observer_.GetPoliciesAppliedCountAndReset()); 532 EXPECT_EQ(1, policy_observer_.GetPoliciesAppliedCountAndReset());
532 VerifyAndClearExpectations(); 533 VerifyAndClearExpectations();
533 534
534 SetUpEntry("policy/shill_policy_on_unmanaged_wifi1.json", 535 SetUpEntry("policy/shill_policy_on_unmanaged_wifi1.json",
535 kUser1ProfilePath, 536 kUser1ProfilePath,
536 "some_entry_path"); 537 "some_entry_path");
537 538
538 EXPECT_CALL(*mock_profile_client_, GetProperties(_, _, _)); 539 EXPECT_CALL(*mock_profile_client_, GetProperties(_, _, _));
539 540
540 EXPECT_CALL( 541 EXPECT_CALL(
541 *mock_profile_client_, 542 *mock_profile_client_,
542 GetEntry(dbus::ObjectPath(kUser1ProfilePath), "some_entry_path", _, _)); 543 GetEntry(dbus::ObjectPath(kUser1ProfilePath), "some_entry_path", _, _));
543 544
544 SetPolicy(::onc::ONC_SOURCE_USER_POLICY, kUser1, "policy/policy_wifi1.onc"); 545 SetPolicy(::onc::ONC_SOURCE_USER_POLICY, kUser1, "policy/policy_wifi1.onc");
545 546
546 message_loop_.RunUntilIdle(); 547 base::RunLoop().RunUntilIdle();
547 EXPECT_EQ(1, policy_observer_.GetPoliciesAppliedCountAndReset()); 548 EXPECT_EQ(1, policy_observer_.GetPoliciesAppliedCountAndReset());
548 } 549 }
549 550
550 TEST_F(ManagedNetworkConfigurationHandlerTest, PolicyApplicationRunning) { 551 TEST_F(ManagedNetworkConfigurationHandlerTest, PolicyApplicationRunning) {
551 InitializeStandardProfiles(); 552 InitializeStandardProfiles();
552 EXPECT_CALL(*mock_profile_client_, GetProperties(_, _, _)).Times(AnyNumber()); 553 EXPECT_CALL(*mock_profile_client_, GetProperties(_, _, _)).Times(AnyNumber());
553 EXPECT_CALL(*mock_manager_client_, ConfigureServiceForProfile(_, _, _, _)) 554 EXPECT_CALL(*mock_manager_client_, ConfigureServiceForProfile(_, _, _, _))
554 .Times(AnyNumber()); 555 .Times(AnyNumber());
555 EXPECT_CALL(*mock_profile_client_, GetEntry(_, _, _, _)).Times(AnyNumber()); 556 EXPECT_CALL(*mock_profile_client_, GetEntry(_, _, _, _)).Times(AnyNumber());
556 557
557 EXPECT_FALSE(managed_handler()->IsAnyPolicyApplicationRunning()); 558 EXPECT_FALSE(managed_handler()->IsAnyPolicyApplicationRunning());
558 559
559 SetPolicy(::onc::ONC_SOURCE_USER_POLICY, kUser1, "policy/policy_wifi1.onc"); 560 SetPolicy(::onc::ONC_SOURCE_USER_POLICY, kUser1, "policy/policy_wifi1.onc");
560 managed_handler()->SetPolicy( 561 managed_handler()->SetPolicy(
561 ::onc::ONC_SOURCE_DEVICE_POLICY, 562 ::onc::ONC_SOURCE_DEVICE_POLICY,
562 std::string(), // no userhash 563 std::string(), // no userhash
563 base::ListValue(), // no device network policy 564 base::ListValue(), // no device network policy
564 base::DictionaryValue()); // no device global config 565 base::DictionaryValue()); // no device global config
565 566
566 EXPECT_TRUE(managed_handler()->IsAnyPolicyApplicationRunning()); 567 EXPECT_TRUE(managed_handler()->IsAnyPolicyApplicationRunning());
567 message_loop_.RunUntilIdle(); 568 base::RunLoop().RunUntilIdle();
568 EXPECT_FALSE(managed_handler()->IsAnyPolicyApplicationRunning()); 569 EXPECT_FALSE(managed_handler()->IsAnyPolicyApplicationRunning());
569 570
570 SetUpEntry("policy/shill_policy_on_unmanaged_wifi1.json", 571 SetUpEntry("policy/shill_policy_on_unmanaged_wifi1.json",
571 kUser1ProfilePath, 572 kUser1ProfilePath,
572 "some_entry_path"); 573 "some_entry_path");
573 574
574 SetPolicy( 575 SetPolicy(
575 ::onc::ONC_SOURCE_USER_POLICY, kUser1, "policy/policy_wifi1_update.onc"); 576 ::onc::ONC_SOURCE_USER_POLICY, kUser1, "policy/policy_wifi1_update.onc");
576 EXPECT_TRUE(managed_handler()->IsAnyPolicyApplicationRunning()); 577 EXPECT_TRUE(managed_handler()->IsAnyPolicyApplicationRunning());
577 message_loop_.RunUntilIdle(); 578 base::RunLoop().RunUntilIdle();
578 EXPECT_FALSE(managed_handler()->IsAnyPolicyApplicationRunning()); 579 EXPECT_FALSE(managed_handler()->IsAnyPolicyApplicationRunning());
579 } 580 }
580 581
581 TEST_F(ManagedNetworkConfigurationHandlerTest, UpdatePolicyAfterFinished) { 582 TEST_F(ManagedNetworkConfigurationHandlerTest, UpdatePolicyAfterFinished) {
582 InitializeStandardProfiles(); 583 InitializeStandardProfiles();
583 EXPECT_CALL(*mock_profile_client_, GetProperties(_, _, _)); 584 EXPECT_CALL(*mock_profile_client_, GetProperties(_, _, _));
584 EXPECT_CALL(*mock_manager_client_, ConfigureServiceForProfile(_, _, _, _)); 585 EXPECT_CALL(*mock_manager_client_, ConfigureServiceForProfile(_, _, _, _));
585 586
586 SetPolicy(::onc::ONC_SOURCE_USER_POLICY, kUser1, "policy/policy_wifi1.onc"); 587 SetPolicy(::onc::ONC_SOURCE_USER_POLICY, kUser1, "policy/policy_wifi1.onc");
587 message_loop_.RunUntilIdle(); 588 base::RunLoop().RunUntilIdle();
588 EXPECT_EQ(1, policy_observer_.GetPoliciesAppliedCountAndReset()); 589 EXPECT_EQ(1, policy_observer_.GetPoliciesAppliedCountAndReset());
589 VerifyAndClearExpectations(); 590 VerifyAndClearExpectations();
590 591
591 SetUpEntry("policy/shill_policy_on_unmanaged_wifi1.json", 592 SetUpEntry("policy/shill_policy_on_unmanaged_wifi1.json",
592 kUser1ProfilePath, 593 kUser1ProfilePath,
593 "some_entry_path"); 594 "some_entry_path");
594 595
595 EXPECT_CALL(*mock_profile_client_, GetProperties(_, _, _)); 596 EXPECT_CALL(*mock_profile_client_, GetProperties(_, _, _));
596 EXPECT_CALL( 597 EXPECT_CALL(
597 *mock_profile_client_, 598 *mock_profile_client_,
598 GetEntry(dbus::ObjectPath(kUser1ProfilePath), "some_entry_path", _, _)); 599 GetEntry(dbus::ObjectPath(kUser1ProfilePath), "some_entry_path", _, _));
599 EXPECT_CALL(*mock_manager_client_, ConfigureServiceForProfile(_, _, _, _)); 600 EXPECT_CALL(*mock_manager_client_, ConfigureServiceForProfile(_, _, _, _));
600 601
601 SetPolicy( 602 SetPolicy(
602 ::onc::ONC_SOURCE_USER_POLICY, kUser1, "policy/policy_wifi1_update.onc"); 603 ::onc::ONC_SOURCE_USER_POLICY, kUser1, "policy/policy_wifi1_update.onc");
603 message_loop_.RunUntilIdle(); 604 base::RunLoop().RunUntilIdle();
604 EXPECT_EQ(1, policy_observer_.GetPoliciesAppliedCountAndReset()); 605 EXPECT_EQ(1, policy_observer_.GetPoliciesAppliedCountAndReset());
605 } 606 }
606 607
607 TEST_F(ManagedNetworkConfigurationHandlerTest, UpdatePolicyBeforeFinished) { 608 TEST_F(ManagedNetworkConfigurationHandlerTest, UpdatePolicyBeforeFinished) {
608 InitializeStandardProfiles(); 609 InitializeStandardProfiles();
609 EXPECT_CALL(*mock_profile_client_, GetProperties(_, _, _)).Times(2); 610 EXPECT_CALL(*mock_profile_client_, GetProperties(_, _, _)).Times(2);
610 EXPECT_CALL(*mock_manager_client_, ConfigureServiceForProfile(_, _, _, _)) 611 EXPECT_CALL(*mock_manager_client_, ConfigureServiceForProfile(_, _, _, _))
611 .Times(2); 612 .Times(2);
612 613
613 SetPolicy(::onc::ONC_SOURCE_USER_POLICY, kUser1, "policy/policy_wifi1.onc"); 614 SetPolicy(::onc::ONC_SOURCE_USER_POLICY, kUser1, "policy/policy_wifi1.onc");
614 // Usually the first call will cause a profile entry to be created, which we 615 // Usually the first call will cause a profile entry to be created, which we
615 // don't fake here. 616 // don't fake here.
616 SetPolicy( 617 SetPolicy(
617 ::onc::ONC_SOURCE_USER_POLICY, kUser1, "policy/policy_wifi1_update.onc"); 618 ::onc::ONC_SOURCE_USER_POLICY, kUser1, "policy/policy_wifi1_update.onc");
618 619
619 message_loop_.RunUntilIdle(); 620 base::RunLoop().RunUntilIdle();
620 EXPECT_EQ(1, policy_observer_.GetPoliciesAppliedCountAndReset()); 621 EXPECT_EQ(1, policy_observer_.GetPoliciesAppliedCountAndReset());
621 } 622 }
622 623
623 TEST_F(ManagedNetworkConfigurationHandlerTest, SetPolicyManageUnmanaged) { 624 TEST_F(ManagedNetworkConfigurationHandlerTest, SetPolicyManageUnmanaged) {
624 InitializeStandardProfiles(); 625 InitializeStandardProfiles();
625 SetUpEntry("policy/shill_unmanaged_wifi1.json", 626 SetUpEntry("policy/shill_unmanaged_wifi1.json",
626 kUser1ProfilePath, 627 kUser1ProfilePath,
627 "old_entry_path"); 628 "old_entry_path");
628 629
629 std::unique_ptr<base::DictionaryValue> expected_shill_properties = 630 std::unique_ptr<base::DictionaryValue> expected_shill_properties =
(...skipping 11 matching lines...) Expand all
641 *mock_profile_client_, 642 *mock_profile_client_,
642 DeleteEntry(dbus::ObjectPath(kUser1ProfilePath), "old_entry_path", _, _)); 643 DeleteEntry(dbus::ObjectPath(kUser1ProfilePath), "old_entry_path", _, _));
643 644
644 EXPECT_CALL(*mock_manager_client_, 645 EXPECT_CALL(*mock_manager_client_,
645 ConfigureServiceForProfile( 646 ConfigureServiceForProfile(
646 dbus::ObjectPath(kUser1ProfilePath), 647 dbus::ObjectPath(kUser1ProfilePath),
647 IsEqualTo(expected_shill_properties.get()), 648 IsEqualTo(expected_shill_properties.get()),
648 _, _)); 649 _, _));
649 650
650 SetPolicy(::onc::ONC_SOURCE_USER_POLICY, kUser1, "policy/policy_wifi1.onc"); 651 SetPolicy(::onc::ONC_SOURCE_USER_POLICY, kUser1, "policy/policy_wifi1.onc");
651 message_loop_.RunUntilIdle(); 652 base::RunLoop().RunUntilIdle();
652 } 653 }
653 654
654 // Old ChromeOS versions may not have used the UIData property 655 // Old ChromeOS versions may not have used the UIData property
655 TEST_F(ManagedNetworkConfigurationHandlerTest, 656 TEST_F(ManagedNetworkConfigurationHandlerTest,
656 SetPolicyManageUnmanagedWithoutUIData) { 657 SetPolicyManageUnmanagedWithoutUIData) {
657 InitializeStandardProfiles(); 658 InitializeStandardProfiles();
658 SetUpEntry("policy/shill_unmanaged_wifi1.json", 659 SetUpEntry("policy/shill_unmanaged_wifi1.json",
659 kUser1ProfilePath, 660 kUser1ProfilePath,
660 "old_entry_path"); 661 "old_entry_path");
661 662
(...skipping 12 matching lines...) Expand all
674 *mock_profile_client_, 675 *mock_profile_client_,
675 DeleteEntry(dbus::ObjectPath(kUser1ProfilePath), "old_entry_path", _, _)); 676 DeleteEntry(dbus::ObjectPath(kUser1ProfilePath), "old_entry_path", _, _));
676 677
677 EXPECT_CALL(*mock_manager_client_, 678 EXPECT_CALL(*mock_manager_client_,
678 ConfigureServiceForProfile( 679 ConfigureServiceForProfile(
679 dbus::ObjectPath(kUser1ProfilePath), 680 dbus::ObjectPath(kUser1ProfilePath),
680 IsEqualTo(expected_shill_properties.get()), 681 IsEqualTo(expected_shill_properties.get()),
681 _, _)); 682 _, _));
682 683
683 SetPolicy(::onc::ONC_SOURCE_USER_POLICY, kUser1, "policy/policy_wifi1.onc"); 684 SetPolicy(::onc::ONC_SOURCE_USER_POLICY, kUser1, "policy/policy_wifi1.onc");
684 message_loop_.RunUntilIdle(); 685 base::RunLoop().RunUntilIdle();
685 } 686 }
686 687
687 TEST_F(ManagedNetworkConfigurationHandlerTest, SetPolicyUpdateManagedNewGUID) { 688 TEST_F(ManagedNetworkConfigurationHandlerTest, SetPolicyUpdateManagedNewGUID) {
688 InitializeStandardProfiles(); 689 InitializeStandardProfiles();
689 SetUpEntry("policy/shill_managed_wifi1.json", 690 SetUpEntry("policy/shill_managed_wifi1.json",
690 kUser1ProfilePath, 691 kUser1ProfilePath,
691 "old_entry_path"); 692 "old_entry_path");
692 693
693 std::unique_ptr<base::DictionaryValue> expected_shill_properties = 694 std::unique_ptr<base::DictionaryValue> expected_shill_properties =
694 test_utils::ReadTestDictionary( 695 test_utils::ReadTestDictionary(
(...skipping 15 matching lines...) Expand all
710 *mock_profile_client_, 711 *mock_profile_client_,
711 DeleteEntry(dbus::ObjectPath(kUser1ProfilePath), "old_entry_path", _, _)); 712 DeleteEntry(dbus::ObjectPath(kUser1ProfilePath), "old_entry_path", _, _));
712 713
713 EXPECT_CALL(*mock_manager_client_, 714 EXPECT_CALL(*mock_manager_client_,
714 ConfigureServiceForProfile( 715 ConfigureServiceForProfile(
715 dbus::ObjectPath(kUser1ProfilePath), 716 dbus::ObjectPath(kUser1ProfilePath),
716 IsEqualTo(expected_shill_properties.get()), 717 IsEqualTo(expected_shill_properties.get()),
717 _, _)); 718 _, _));
718 719
719 SetPolicy(::onc::ONC_SOURCE_USER_POLICY, kUser1, "policy/policy_wifi1.onc"); 720 SetPolicy(::onc::ONC_SOURCE_USER_POLICY, kUser1, "policy/policy_wifi1.onc");
720 message_loop_.RunUntilIdle(); 721 base::RunLoop().RunUntilIdle();
721 } 722 }
722 723
723 TEST_F(ManagedNetworkConfigurationHandlerTest, SetPolicyUpdateManagedVPN) { 724 TEST_F(ManagedNetworkConfigurationHandlerTest, SetPolicyUpdateManagedVPN) {
724 InitializeStandardProfiles(); 725 InitializeStandardProfiles();
725 SetUpEntry("policy/shill_managed_vpn.json", kUser1ProfilePath, "entry_path"); 726 SetUpEntry("policy/shill_managed_vpn.json", kUser1ProfilePath, "entry_path");
726 727
727 std::unique_ptr<base::DictionaryValue> expected_shill_properties = 728 std::unique_ptr<base::DictionaryValue> expected_shill_properties =
728 test_utils::ReadTestDictionary("policy/shill_policy_on_managed_vpn.json"); 729 test_utils::ReadTestDictionary("policy/shill_policy_on_managed_vpn.json");
729 730
730 EXPECT_CALL(*mock_profile_client_, 731 EXPECT_CALL(*mock_profile_client_,
731 GetProperties(dbus::ObjectPath(kUser1ProfilePath), _, _)); 732 GetProperties(dbus::ObjectPath(kUser1ProfilePath), _, _));
732 733
733 EXPECT_CALL( 734 EXPECT_CALL(
734 *mock_profile_client_, 735 *mock_profile_client_,
735 GetEntry(dbus::ObjectPath(kUser1ProfilePath), "entry_path", _, _)); 736 GetEntry(dbus::ObjectPath(kUser1ProfilePath), "entry_path", _, _));
736 737
737 EXPECT_CALL(*mock_manager_client_, 738 EXPECT_CALL(*mock_manager_client_,
738 ConfigureServiceForProfile( 739 ConfigureServiceForProfile(
739 dbus::ObjectPath(kUser1ProfilePath), 740 dbus::ObjectPath(kUser1ProfilePath),
740 IsEqualTo(expected_shill_properties.get()), 741 IsEqualTo(expected_shill_properties.get()),
741 _, _)); 742 _, _));
742 743
743 SetPolicy(::onc::ONC_SOURCE_USER_POLICY, kUser1, "policy/policy_vpn.onc"); 744 SetPolicy(::onc::ONC_SOURCE_USER_POLICY, kUser1, "policy/policy_vpn.onc");
744 message_loop_.RunUntilIdle(); 745 base::RunLoop().RunUntilIdle();
745 VerifyAndClearExpectations(); 746 VerifyAndClearExpectations();
746 } 747 }
747 748
748 TEST_F(ManagedNetworkConfigurationHandlerTest, SetPolicyReapplyToManaged) { 749 TEST_F(ManagedNetworkConfigurationHandlerTest, SetPolicyReapplyToManaged) {
749 InitializeStandardProfiles(); 750 InitializeStandardProfiles();
750 SetUpEntry("policy/shill_policy_on_unmanaged_wifi1.json", 751 SetUpEntry("policy/shill_policy_on_unmanaged_wifi1.json",
751 kUser1ProfilePath, 752 kUser1ProfilePath,
752 "old_entry_path"); 753 "old_entry_path");
753 754
754 std::unique_ptr<base::DictionaryValue> expected_shill_properties = 755 std::unique_ptr<base::DictionaryValue> expected_shill_properties =
(...skipping 12 matching lines...) Expand all
767 *mock_profile_client_, 768 *mock_profile_client_,
768 GetEntry(dbus::ObjectPath(kUser1ProfilePath), "old_entry_path", _, _)); 769 GetEntry(dbus::ObjectPath(kUser1ProfilePath), "old_entry_path", _, _));
769 770
770 EXPECT_CALL(*mock_manager_client_, 771 EXPECT_CALL(*mock_manager_client_,
771 ConfigureServiceForProfile( 772 ConfigureServiceForProfile(
772 dbus::ObjectPath(kUser1ProfilePath), 773 dbus::ObjectPath(kUser1ProfilePath),
773 IsEqualTo(expected_shill_properties.get()), 774 IsEqualTo(expected_shill_properties.get()),
774 _, _)); 775 _, _));
775 776
776 SetPolicy(::onc::ONC_SOURCE_USER_POLICY, kUser1, "policy/policy_wifi1.onc"); 777 SetPolicy(::onc::ONC_SOURCE_USER_POLICY, kUser1, "policy/policy_wifi1.onc");
777 message_loop_.RunUntilIdle(); 778 base::RunLoop().RunUntilIdle();
778 VerifyAndClearExpectations(); 779 VerifyAndClearExpectations();
779 780
780 // If we apply the policy again, without change, then the Shill profile will 781 // If we apply the policy again, without change, then the Shill profile will
781 // not be modified. 782 // not be modified.
782 EXPECT_CALL(*mock_profile_client_, 783 EXPECT_CALL(*mock_profile_client_,
783 GetProperties(dbus::ObjectPath(kUser1ProfilePath), _, _)); 784 GetProperties(dbus::ObjectPath(kUser1ProfilePath), _, _));
784 785
785 EXPECT_CALL( 786 EXPECT_CALL(
786 *mock_profile_client_, 787 *mock_profile_client_,
787 GetEntry(dbus::ObjectPath(kUser1ProfilePath), "old_entry_path", _, _)); 788 GetEntry(dbus::ObjectPath(kUser1ProfilePath), "old_entry_path", _, _));
788 789
789 SetPolicy(::onc::ONC_SOURCE_USER_POLICY, kUser1, "policy/policy_wifi1.onc"); 790 SetPolicy(::onc::ONC_SOURCE_USER_POLICY, kUser1, "policy/policy_wifi1.onc");
790 message_loop_.RunUntilIdle(); 791 base::RunLoop().RunUntilIdle();
791 } 792 }
792 793
793 TEST_F(ManagedNetworkConfigurationHandlerTest, SetPolicyUnmanageManaged) { 794 TEST_F(ManagedNetworkConfigurationHandlerTest, SetPolicyUnmanageManaged) {
794 InitializeStandardProfiles(); 795 InitializeStandardProfiles();
795 SetUpEntry("policy/shill_policy_on_unmanaged_wifi1.json", 796 SetUpEntry("policy/shill_policy_on_unmanaged_wifi1.json",
796 kUser1ProfilePath, 797 kUser1ProfilePath,
797 "old_entry_path"); 798 "old_entry_path");
798 799
799 EXPECT_CALL(*mock_profile_client_, 800 EXPECT_CALL(*mock_profile_client_,
800 GetProperties(dbus::ObjectPath(kUser1ProfilePath), _, _)); 801 GetProperties(dbus::ObjectPath(kUser1ProfilePath), _, _));
801 802
802 EXPECT_CALL(*mock_profile_client_, 803 EXPECT_CALL(*mock_profile_client_,
803 GetEntry(dbus::ObjectPath(kUser1ProfilePath), 804 GetEntry(dbus::ObjectPath(kUser1ProfilePath),
804 "old_entry_path", 805 "old_entry_path",
805 _, _)); 806 _, _));
806 807
807 EXPECT_CALL(*mock_profile_client_, 808 EXPECT_CALL(*mock_profile_client_,
808 DeleteEntry(dbus::ObjectPath(kUser1ProfilePath), 809 DeleteEntry(dbus::ObjectPath(kUser1ProfilePath),
809 "old_entry_path", 810 "old_entry_path",
810 _, _)); 811 _, _));
811 812
812 SetPolicy(::onc::ONC_SOURCE_USER_POLICY, kUser1, ""); 813 SetPolicy(::onc::ONC_SOURCE_USER_POLICY, kUser1, "");
813 message_loop_.RunUntilIdle(); 814 base::RunLoop().RunUntilIdle();
814 } 815 }
815 816
816 TEST_F(ManagedNetworkConfigurationHandlerTest, SetEmptyPolicyIgnoreUnmanaged) { 817 TEST_F(ManagedNetworkConfigurationHandlerTest, SetEmptyPolicyIgnoreUnmanaged) {
817 InitializeStandardProfiles(); 818 InitializeStandardProfiles();
818 SetUpEntry("policy/shill_unmanaged_wifi1.json", 819 SetUpEntry("policy/shill_unmanaged_wifi1.json",
819 kUser1ProfilePath, 820 kUser1ProfilePath,
820 "old_entry_path"); 821 "old_entry_path");
821 822
822 EXPECT_CALL(*mock_profile_client_, 823 EXPECT_CALL(*mock_profile_client_,
823 GetProperties(dbus::ObjectPath(kUser1ProfilePath), _, _)); 824 GetProperties(dbus::ObjectPath(kUser1ProfilePath), _, _));
824 825
825 EXPECT_CALL(*mock_profile_client_, 826 EXPECT_CALL(*mock_profile_client_,
826 GetEntry(dbus::ObjectPath(kUser1ProfilePath), 827 GetEntry(dbus::ObjectPath(kUser1ProfilePath),
827 "old_entry_path", 828 "old_entry_path",
828 _, _)); 829 _, _));
829 830
830 SetPolicy(::onc::ONC_SOURCE_USER_POLICY, kUser1, ""); 831 SetPolicy(::onc::ONC_SOURCE_USER_POLICY, kUser1, "");
831 message_loop_.RunUntilIdle(); 832 base::RunLoop().RunUntilIdle();
832 EXPECT_EQ(1, policy_observer_.GetPoliciesAppliedCountAndReset()); 833 EXPECT_EQ(1, policy_observer_.GetPoliciesAppliedCountAndReset());
833 } 834 }
834 835
835 TEST_F(ManagedNetworkConfigurationHandlerTest, SetPolicyIgnoreUnmanaged) { 836 TEST_F(ManagedNetworkConfigurationHandlerTest, SetPolicyIgnoreUnmanaged) {
836 InitializeStandardProfiles(); 837 InitializeStandardProfiles();
837 SetUpEntry("policy/shill_unmanaged_wifi2.json", 838 SetUpEntry("policy/shill_unmanaged_wifi2.json",
838 kUser1ProfilePath, 839 kUser1ProfilePath,
839 "wifi2_entry_path"); 840 "wifi2_entry_path");
840 841
841 EXPECT_CALL(*mock_profile_client_, 842 EXPECT_CALL(*mock_profile_client_,
842 GetProperties(dbus::ObjectPath(kUser1ProfilePath), _, _)); 843 GetProperties(dbus::ObjectPath(kUser1ProfilePath), _, _));
843 844
844 EXPECT_CALL( 845 EXPECT_CALL(
845 *mock_profile_client_, 846 *mock_profile_client_,
846 GetEntry(dbus::ObjectPath(kUser1ProfilePath), "wifi2_entry_path", _, _)); 847 GetEntry(dbus::ObjectPath(kUser1ProfilePath), "wifi2_entry_path", _, _));
847 848
848 std::unique_ptr<base::DictionaryValue> expected_shill_properties = 849 std::unique_ptr<base::DictionaryValue> expected_shill_properties =
849 test_utils::ReadTestDictionary( 850 test_utils::ReadTestDictionary(
850 "policy/shill_policy_on_unconfigured_wifi1.json"); 851 "policy/shill_policy_on_unconfigured_wifi1.json");
851 852
852 EXPECT_CALL(*mock_manager_client_, 853 EXPECT_CALL(*mock_manager_client_,
853 ConfigureServiceForProfile( 854 ConfigureServiceForProfile(
854 dbus::ObjectPath(kUser1ProfilePath), 855 dbus::ObjectPath(kUser1ProfilePath),
855 IsEqualTo(expected_shill_properties.get()), 856 IsEqualTo(expected_shill_properties.get()),
856 _, _)); 857 _, _));
857 858
858 SetPolicy(::onc::ONC_SOURCE_USER_POLICY, kUser1, "policy/policy_wifi1.onc"); 859 SetPolicy(::onc::ONC_SOURCE_USER_POLICY, kUser1, "policy/policy_wifi1.onc");
859 message_loop_.RunUntilIdle(); 860 base::RunLoop().RunUntilIdle();
860 } 861 }
861 862
862 TEST_F(ManagedNetworkConfigurationHandlerTest, AutoConnectDisallowed) { 863 TEST_F(ManagedNetworkConfigurationHandlerTest, AutoConnectDisallowed) {
863 InitializeStandardProfiles(); 864 InitializeStandardProfiles();
864 // Setup an unmanaged network. 865 // Setup an unmanaged network.
865 SetUpEntry("policy/shill_unmanaged_wifi2.json", 866 SetUpEntry("policy/shill_unmanaged_wifi2.json",
866 kUser1ProfilePath, 867 kUser1ProfilePath,
867 "wifi2_entry_path"); 868 "wifi2_entry_path");
868 869
869 // Apply the user policy with global autoconnect config and expect that 870 // Apply the user policy with global autoconnect config and expect that
(...skipping 10 matching lines...) Expand all
880 "policy/shill_disallow_autoconnect_on_unmanaged_wifi2.json"); 881 "policy/shill_disallow_autoconnect_on_unmanaged_wifi2.json");
881 882
882 EXPECT_CALL(*mock_manager_client_, 883 EXPECT_CALL(*mock_manager_client_,
883 ConfigureServiceForProfile( 884 ConfigureServiceForProfile(
884 dbus::ObjectPath(kUser1ProfilePath), 885 dbus::ObjectPath(kUser1ProfilePath),
885 MatchesProperties(expected_shill_properties.get()), _, _)); 886 MatchesProperties(expected_shill_properties.get()), _, _));
886 887
887 SetPolicy(::onc::ONC_SOURCE_USER_POLICY, 888 SetPolicy(::onc::ONC_SOURCE_USER_POLICY,
888 kUser1, 889 kUser1,
889 "policy/policy_disallow_autoconnect.onc"); 890 "policy/policy_disallow_autoconnect.onc");
890 message_loop_.RunUntilIdle(); 891 base::RunLoop().RunUntilIdle();
891 892
892 // Verify that GetManagedProperties correctly augments the properties with the 893 // Verify that GetManagedProperties correctly augments the properties with the
893 // global config from the user policy. 894 // global config from the user policy.
894 895
895 // GetManagedProperties requires the device policy to be set or explicitly 896 // GetManagedProperties requires the device policy to be set or explicitly
896 // unset. 897 // unset.
897 EXPECT_CALL(*mock_profile_client_, 898 EXPECT_CALL(*mock_profile_client_,
898 GetProperties(dbus::ObjectPath( 899 GetProperties(dbus::ObjectPath(
899 NetworkProfileHandler::GetSharedProfilePath()), 900 NetworkProfileHandler::GetSharedProfilePath()),
900 _, 901 _,
901 _)); 902 _));
902 managed_handler()->SetPolicy( 903 managed_handler()->SetPolicy(
903 ::onc::ONC_SOURCE_DEVICE_POLICY, 904 ::onc::ONC_SOURCE_DEVICE_POLICY,
904 std::string(), // no userhash 905 std::string(), // no userhash
905 base::ListValue(), // no device network policy 906 base::ListValue(), // no device network policy
906 base::DictionaryValue()); // no device global config 907 base::DictionaryValue()); // no device global config
907 908
908 services_stub_.SetFakeProperties(*expected_shill_properties); 909 services_stub_.SetFakeProperties(*expected_shill_properties);
909 EXPECT_CALL(*mock_service_client_, 910 EXPECT_CALL(*mock_service_client_,
910 GetProperties(dbus::ObjectPath( 911 GetProperties(dbus::ObjectPath(
911 "wifi2"),_)); 912 "wifi2"),_));
912 913
913 GetManagedProperties(kUser1, "wifi2"); 914 GetManagedProperties(kUser1, "wifi2");
914 message_loop_.RunUntilIdle(); 915 base::RunLoop().RunUntilIdle();
915 916
916 EXPECT_EQ("wifi2", get_properties_service_path_); 917 EXPECT_EQ("wifi2", get_properties_service_path_);
917 918
918 std::unique_ptr<base::DictionaryValue> expected_managed_onc = 919 std::unique_ptr<base::DictionaryValue> expected_managed_onc =
919 test_utils::ReadTestDictionary( 920 test_utils::ReadTestDictionary(
920 "policy/managed_onc_disallow_autoconnect_on_unmanaged_wifi2.onc"); 921 "policy/managed_onc_disallow_autoconnect_on_unmanaged_wifi2.onc");
921 EXPECT_TRUE(onc::test_utils::Equals(expected_managed_onc.get(), 922 EXPECT_TRUE(onc::test_utils::Equals(expected_managed_onc.get(),
922 &get_properties_result_)); 923 &get_properties_result_));
923 } 924 }
924 925
925 TEST_F(ManagedNetworkConfigurationHandlerTest, LateProfileLoading) { 926 TEST_F(ManagedNetworkConfigurationHandlerTest, LateProfileLoading) {
926 SetPolicy(::onc::ONC_SOURCE_USER_POLICY, kUser1, "policy/policy_wifi1.onc"); 927 SetPolicy(::onc::ONC_SOURCE_USER_POLICY, kUser1, "policy/policy_wifi1.onc");
927 928
928 message_loop_.RunUntilIdle(); 929 base::RunLoop().RunUntilIdle();
929 VerifyAndClearExpectations(); 930 VerifyAndClearExpectations();
930 931
931 std::unique_ptr<base::DictionaryValue> expected_shill_properties = 932 std::unique_ptr<base::DictionaryValue> expected_shill_properties =
932 test_utils::ReadTestDictionary( 933 test_utils::ReadTestDictionary(
933 "policy/shill_policy_on_unconfigured_wifi1.json"); 934 "policy/shill_policy_on_unconfigured_wifi1.json");
934 935
935 EXPECT_CALL(*mock_profile_client_, 936 EXPECT_CALL(*mock_profile_client_,
936 GetProperties(dbus::ObjectPath(kUser1ProfilePath), _, _)); 937 GetProperties(dbus::ObjectPath(kUser1ProfilePath), _, _));
937 938
938 EXPECT_CALL(*mock_manager_client_, 939 EXPECT_CALL(*mock_manager_client_,
939 ConfigureServiceForProfile( 940 ConfigureServiceForProfile(
940 dbus::ObjectPath(kUser1ProfilePath), 941 dbus::ObjectPath(kUser1ProfilePath),
941 IsEqualTo(expected_shill_properties.get()), 942 IsEqualTo(expected_shill_properties.get()),
942 _, _)); 943 _, _));
943 944
944 InitializeStandardProfiles(); 945 InitializeStandardProfiles();
945 message_loop_.RunUntilIdle(); 946 base::RunLoop().RunUntilIdle();
946 } 947 }
947 948
948 class ManagedNetworkConfigurationHandlerShutdownTest 949 class ManagedNetworkConfigurationHandlerShutdownTest
949 : public ManagedNetworkConfigurationHandlerTest { 950 : public ManagedNetworkConfigurationHandlerTest {
950 public: 951 public:
951 void SetUp() override { 952 void SetUp() override {
952 ManagedNetworkConfigurationHandlerTest::SetUp(); 953 ManagedNetworkConfigurationHandlerTest::SetUp();
953 ON_CALL(*mock_profile_client_, GetProperties(_, _, _)).WillByDefault( 954 ON_CALL(*mock_profile_client_, GetProperties(_, _, _)).WillByDefault(
954 Invoke(&ManagedNetworkConfigurationHandlerShutdownTest::GetProperties)); 955 Invoke(&ManagedNetworkConfigurationHandlerShutdownTest::GetProperties));
955 } 956 }
(...skipping 17 matching lines...) Expand all
973 TEST_F(ManagedNetworkConfigurationHandlerShutdownTest, 974 TEST_F(ManagedNetworkConfigurationHandlerShutdownTest,
974 DuringPolicyApplication) { 975 DuringPolicyApplication) {
975 InitializeStandardProfiles(); 976 InitializeStandardProfiles();
976 977
977 EXPECT_CALL(*mock_profile_client_, 978 EXPECT_CALL(*mock_profile_client_,
978 GetProperties(dbus::ObjectPath(kUser1ProfilePath), _, _)); 979 GetProperties(dbus::ObjectPath(kUser1ProfilePath), _, _));
979 980
980 SetPolicy(::onc::ONC_SOURCE_USER_POLICY, kUser1, "policy/policy_wifi1.onc"); 981 SetPolicy(::onc::ONC_SOURCE_USER_POLICY, kUser1, "policy/policy_wifi1.onc");
981 managed_network_configuration_handler_->RemoveObserver(&policy_observer_); 982 managed_network_configuration_handler_->RemoveObserver(&policy_observer_);
982 managed_network_configuration_handler_.reset(); 983 managed_network_configuration_handler_.reset();
983 message_loop_.RunUntilIdle(); 984 base::RunLoop().RunUntilIdle();
984 } 985 }
985 986
986 } // namespace chromeos 987 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698