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

Side by Side Diff: chrome/browser/chromeos/arc/arc_session_manager_unittest.cc

Issue 2782553004: Move TestingPrefService to use unique_ptr<Value> (Closed)
Patch Set: comments Created 3 years, 8 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 <memory> 5 #include <memory>
6 #include <string> 6 #include <string>
7 #include <tuple> 7 #include <tuple>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 TEST_P(ArcSessionManagerPolicyTest, SkippingTerms) { 493 TEST_P(ArcSessionManagerPolicyTest, SkippingTerms) {
494 sync_preferences::TestingPrefServiceSyncable* const prefs = 494 sync_preferences::TestingPrefServiceSyncable* const prefs =
495 profile()->GetTestingPrefService(); 495 profile()->GetTestingPrefService();
496 496
497 // Backup-restore and location-service prefs are off by default. 497 // Backup-restore and location-service prefs are off by default.
498 EXPECT_FALSE(prefs->GetBoolean(prefs::kArcSignedIn)); 498 EXPECT_FALSE(prefs->GetBoolean(prefs::kArcSignedIn));
499 EXPECT_FALSE(prefs->GetBoolean(prefs::kArcTermsAccepted)); 499 EXPECT_FALSE(prefs->GetBoolean(prefs::kArcTermsAccepted));
500 500
501 // Enable ARC through user pref or by policy, according to the test parameter. 501 // Enable ARC through user pref or by policy, according to the test parameter.
502 if (arc_enabled_pref_managed()) 502 if (arc_enabled_pref_managed())
503 prefs->SetManagedPref(prefs::kArcEnabled, new base::Value(true)); 503 prefs->SetManagedPref(prefs::kArcEnabled,
504 base::MakeUnique<base::Value>(true));
504 else 505 else
505 prefs->SetBoolean(prefs::kArcEnabled, true); 506 prefs->SetBoolean(prefs::kArcEnabled, true);
506 EXPECT_TRUE(IsArcPlayStoreEnabledForProfile(profile())); 507 EXPECT_TRUE(IsArcPlayStoreEnabledForProfile(profile()));
507 508
508 // Assign test values to the prefs. 509 // Assign test values to the prefs.
509 if (backup_restore_pref_value().is_bool()) { 510 if (backup_restore_pref_value().is_bool()) {
510 prefs->SetManagedPref(prefs::kArcBackupRestoreEnabled, 511 prefs->SetManagedPref(prefs::kArcBackupRestoreEnabled,
511 backup_restore_pref_value().DeepCopy()); 512 backup_restore_pref_value().CreateDeepCopy());
512 } 513 }
513 if (location_service_pref_value().is_bool()) { 514 if (location_service_pref_value().is_bool()) {
514 prefs->SetManagedPref(prefs::kArcLocationServiceEnabled, 515 prefs->SetManagedPref(prefs::kArcLocationServiceEnabled,
515 location_service_pref_value().DeepCopy()); 516 location_service_pref_value().CreateDeepCopy());
516 } 517 }
517 518
518 arc_session_manager()->SetProfile(profile()); 519 arc_session_manager()->SetProfile(profile());
519 arc_session_manager()->RequestEnable(); 520 arc_session_manager()->RequestEnable();
520 521
521 // Terms of Service are skipped iff ARC is enabled by policy and both 522 // Terms of Service are skipped iff ARC is enabled by policy and both
522 // ArcBackupRestoreEnabled and ArcLocationServiceEnabled are managed. 523 // ArcBackupRestoreEnabled and ArcLocationServiceEnabled are managed.
523 const bool expected_terms_skipping = arc_enabled_pref_managed() && 524 const bool expected_terms_skipping = arc_enabled_pref_managed() &&
524 backup_restore_pref_value().is_bool() && 525 backup_restore_pref_value().is_bool() &&
525 location_service_pref_value().is_bool(); 526 location_service_pref_value().is_bool();
(...skipping 27 matching lines...) Expand all
553 prefs->RemoveManagedPref(prefs::kArcEnabled); 554 prefs->RemoveManagedPref(prefs::kArcEnabled);
554 WaitForDataRemoved(ArcSessionManager::State::STOPPED); 555 WaitForDataRemoved(ArcSessionManager::State::STOPPED);
555 arc_session_manager()->Shutdown(); 556 arc_session_manager()->Shutdown();
556 } 557 }
557 558
558 TEST_P(ArcSessionManagerPolicyTest, ReenableManagedArc) { 559 TEST_P(ArcSessionManagerPolicyTest, ReenableManagedArc) {
559 sync_preferences::TestingPrefServiceSyncable* const prefs = 560 sync_preferences::TestingPrefServiceSyncable* const prefs =
560 profile()->GetTestingPrefService(); 561 profile()->GetTestingPrefService();
561 562
562 // Set ARC to be managed. 563 // Set ARC to be managed.
563 prefs->SetManagedPref(prefs::kArcEnabled, new base::Value(true)); 564 prefs->SetManagedPref(prefs::kArcEnabled,
565 base::MakeUnique<base::Value>(true));
564 EXPECT_TRUE(arc::IsArcPlayStoreEnabledForProfile(profile())); 566 EXPECT_TRUE(arc::IsArcPlayStoreEnabledForProfile(profile()));
565 567
566 arc_session_manager()->SetProfile(profile()); 568 arc_session_manager()->SetProfile(profile());
567 arc_session_manager()->RequestEnable(); 569 arc_session_manager()->RequestEnable();
568 EXPECT_TRUE(arc_session_manager()->enable_requested()); 570 EXPECT_TRUE(arc_session_manager()->enable_requested());
569 571
570 // Simulate close OptIn. Session manager should stop. 572 // Simulate close OptIn. Session manager should stop.
571 SetArcPlayStoreEnabledForProfile(profile(), false); 573 SetArcPlayStoreEnabledForProfile(profile(), false);
572 EXPECT_TRUE(arc::IsArcPlayStoreEnabledForProfile(profile())); 574 EXPECT_TRUE(arc::IsArcPlayStoreEnabledForProfile(profile()));
573 EXPECT_FALSE(arc_session_manager()->enable_requested()); 575 EXPECT_FALSE(arc_session_manager()->enable_requested());
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 GetFakeUserManager()->set_current_user_new(true); 687 GetFakeUserManager()->set_current_user_new(true);
686 688
687 CreateLoginDisplayHost(); 689 CreateLoginDisplayHost();
688 690
689 if (IsManagedUser()) { 691 if (IsManagedUser()) {
690 policy::ProfilePolicyConnector* const connector = 692 policy::ProfilePolicyConnector* const connector =
691 policy::ProfilePolicyConnectorFactory::GetForBrowserContext( 693 policy::ProfilePolicyConnectorFactory::GetForBrowserContext(
692 profile()); 694 profile());
693 connector->OverrideIsManagedForTesting(true); 695 connector->OverrideIsManagedForTesting(true);
694 696
695 profile()->GetTestingPrefService()->SetManagedPref(prefs::kArcEnabled, 697 profile()->GetTestingPrefService()->SetManagedPref(
696 new base::Value(true)); 698 prefs::kArcEnabled, base::MakeUnique<base::Value>(true));
697 } 699 }
698 700
699 arc_session_manager()->SetProfile(profile()); 701 arc_session_manager()->SetProfile(profile());
700 if (IsArcPlayStoreEnabledForProfile(profile())) 702 if (IsArcPlayStoreEnabledForProfile(profile()))
701 arc_session_manager()->RequestEnable(); 703 arc_session_manager()->RequestEnable();
702 } 704 }
703 705
704 void TearDown() override { 706 void TearDown() override {
705 // Correctly stop service. 707 // Correctly stop service.
706 arc_session_manager()->Shutdown(); 708 arc_session_manager()->Shutdown();
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
808 // For managed case we handle closing outside of 810 // For managed case we handle closing outside of
809 // ArcPlayStoreEnabledPreferenceHandler. So it session turns to STOPPED. 811 // ArcPlayStoreEnabledPreferenceHandler. So it session turns to STOPPED.
810 EXPECT_EQ(ArcSessionManager::State::STOPPED, 812 EXPECT_EQ(ArcSessionManager::State::STOPPED,
811 arc_session_manager()->state()); 813 arc_session_manager()->state());
812 // Managed user's preference should not be overwritten. 814 // Managed user's preference should not be overwritten.
813 EXPECT_TRUE(IsArcPlayStoreEnabledForProfile(profile())); 815 EXPECT_TRUE(IsArcPlayStoreEnabledForProfile(profile()));
814 } 816 }
815 } 817 }
816 818
817 } // namespace arc 819 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698