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

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

Issue 2739323004: arc: Reactivate OptIn flow on clicking Play Store. (Closed)
Patch Set: TODO added/rebased Created 3 years, 9 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 537 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 EXPECT_EQ(ArcSessionManager::State::ACTIVE, arc_session_manager()->state()); 548 EXPECT_EQ(ArcSessionManager::State::ACTIVE, arc_session_manager()->state());
549 EXPECT_FALSE(prefs->GetBoolean(prefs::kArcBackupRestoreEnabled)); 549 EXPECT_FALSE(prefs->GetBoolean(prefs::kArcBackupRestoreEnabled));
550 EXPECT_FALSE(prefs->GetBoolean(prefs::kArcLocationServiceEnabled)); 550 EXPECT_FALSE(prefs->GetBoolean(prefs::kArcLocationServiceEnabled));
551 551
552 // Stop ARC and shutdown the service. 552 // Stop ARC and shutdown the service.
553 prefs->RemoveManagedPref(prefs::kArcEnabled); 553 prefs->RemoveManagedPref(prefs::kArcEnabled);
554 WaitForDataRemoved(ArcSessionManager::State::STOPPED); 554 WaitForDataRemoved(ArcSessionManager::State::STOPPED);
555 arc_session_manager()->Shutdown(); 555 arc_session_manager()->Shutdown();
556 } 556 }
557 557
558 TEST_P(ArcSessionManagerPolicyTest, ReenableManagedArc) {
559 sync_preferences::TestingPrefServiceSyncable* const prefs =
560 profile()->GetTestingPrefService();
561
562 // Set ARC to be managed.
563 prefs->SetManagedPref(prefs::kArcEnabled, new base::Value(true));
564 EXPECT_TRUE(arc::IsArcPlayStoreEnabledForProfile(profile()));
565
566 arc_session_manager()->SetProfile(profile());
567 arc_session_manager()->RequestEnable();
568 EXPECT_TRUE(arc_session_manager()->enable_requested());
569
570 // Simulate close OptIn. Session manager should stop.
571 SetArcPlayStoreEnabledForProfile(profile(), false);
572 EXPECT_TRUE(arc::IsArcPlayStoreEnabledForProfile(profile()));
573 EXPECT_FALSE(arc_session_manager()->enable_requested());
574
575 // Restart ARC again
576 SetArcPlayStoreEnabledForProfile(profile(), true);
577 EXPECT_TRUE(arc::IsArcPlayStoreEnabledForProfile(profile()));
578 EXPECT_TRUE(arc_session_manager()->enable_requested());
579
580 arc_session_manager()->Shutdown();
581 }
582
558 INSTANTIATE_TEST_CASE_P( 583 INSTANTIATE_TEST_CASE_P(
559 ArcSessionManagerPolicyTest, 584 ArcSessionManagerPolicyTest,
560 ArcSessionManagerPolicyTest, 585 ArcSessionManagerPolicyTest,
561 testing::Combine( 586 testing::Combine(
562 testing::Values(false, true) /* arc_enabled_pref_managed */, 587 testing::Values(false, true) /* arc_enabled_pref_managed */,
563 testing::Values(base::Value(), 588 testing::Values(base::Value(),
564 base::Value(false), 589 base::Value(false),
565 base::Value(true)) /* backup_restore_pref_value */, 590 base::Value(true)) /* backup_restore_pref_value */,
566 testing::Values(base::Value(), 591 testing::Values(base::Value(),
567 base::Value(false), 592 base::Value(false),
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
744 arc_session_manager()->state()); 769 arc_session_manager()->state());
745 ReportResult(true); 770 ReportResult(true);
746 EXPECT_EQ(ArcSessionManager::State::ACTIVE, arc_session_manager()->state()); 771 EXPECT_EQ(ArcSessionManager::State::ACTIVE, arc_session_manager()->state());
747 } 772 }
748 773
749 TEST_P(ArcSessionOobeOptInNegotiatorTest, OobeTermsRejected) { 774 TEST_P(ArcSessionOobeOptInNegotiatorTest, OobeTermsRejected) {
750 view()->Show(); 775 view()->Show();
751 EXPECT_EQ(ArcSessionManager::State::NEGOTIATING_TERMS_OF_SERVICE, 776 EXPECT_EQ(ArcSessionManager::State::NEGOTIATING_TERMS_OF_SERVICE,
752 arc_session_manager()->state()); 777 arc_session_manager()->state());
753 ReportResult(false); 778 ReportResult(false);
754 // ArcPlayStoreEnabledPreferenceHandler is not running, so the state should 779 if (!IsManagedUser()) {
755 // be kept as is. 780 // ArcPlayStoreEnabledPreferenceHandler is not running, so the state should
756 EXPECT_EQ(ArcSessionManager::State::NEGOTIATING_TERMS_OF_SERVICE, 781 // be kept as is
757 arc_session_manager()->state()); 782 EXPECT_EQ(ArcSessionManager::State::NEGOTIATING_TERMS_OF_SERVICE,
758 // Managed user's preference should not be overwritten. 783 arc_session_manager()->state());
759 if (!IsManagedUser())
760 EXPECT_FALSE(IsArcPlayStoreEnabledForProfile(profile())); 784 EXPECT_FALSE(IsArcPlayStoreEnabledForProfile(profile()));
785 } else {
786 // For managed case we handle closing outside of
787 // ArcPlayStoreEnabledPreferenceHandler. So it session turns to STOPPED.
788 EXPECT_EQ(ArcSessionManager::State::STOPPED,
789 arc_session_manager()->state());
790 // Managed user's preference should not be overwritten.
791 EXPECT_TRUE(IsArcPlayStoreEnabledForProfile(profile()));
792 }
761 } 793 }
762 794
763 TEST_P(ArcSessionOobeOptInNegotiatorTest, OobeTermsViewDestroyed) { 795 TEST_P(ArcSessionOobeOptInNegotiatorTest, OobeTermsViewDestroyed) {
764 view()->Show(); 796 view()->Show();
765 EXPECT_EQ(ArcSessionManager::State::NEGOTIATING_TERMS_OF_SERVICE, 797 EXPECT_EQ(ArcSessionManager::State::NEGOTIATING_TERMS_OF_SERVICE,
766 arc_session_manager()->state()); 798 arc_session_manager()->state());
767 CloseLoginDisplayHost(); 799 CloseLoginDisplayHost();
768 ReportViewDestroyed(); 800 ReportViewDestroyed();
769 // ArcPlayStoreEnabledPreferenceHandler is not running, so the state should 801 if (!IsManagedUser()) {
770 // be kept as is. 802 // ArcPlayStoreEnabledPreferenceHandler is not running, so the state should
771 EXPECT_EQ(ArcSessionManager::State::NEGOTIATING_TERMS_OF_SERVICE, 803 // be kept as is.
772 arc_session_manager()->state()); 804 EXPECT_EQ(ArcSessionManager::State::NEGOTIATING_TERMS_OF_SERVICE,
773 // Managed user's preference should not be overwritten. 805 arc_session_manager()->state());
774 if (!IsManagedUser())
775 EXPECT_FALSE(IsArcPlayStoreEnabledForProfile(profile())); 806 EXPECT_FALSE(IsArcPlayStoreEnabledForProfile(profile()));
807 } else {
808 // For managed case we handle closing outside of
809 // ArcPlayStoreEnabledPreferenceHandler. So it session turns to STOPPED.
810 EXPECT_EQ(ArcSessionManager::State::STOPPED,
811 arc_session_manager()->state());
812 // Managed user's preference should not be overwritten.
813 EXPECT_TRUE(IsArcPlayStoreEnabledForProfile(profile()));
814 }
776 } 815 }
777 816
778 } // namespace arc 817 } // namespace arc
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/arc/arc_session_manager.h ('k') | chrome/browser/chromeos/arc/arc_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698