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

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

Issue 2755073003: [Merge M58] arc: Reactivate OptIn flow on clicking Play Store. (Closed)
Patch Set: update unit_tests expectation for M58 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 491 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 EXPECT_EQ(ArcSessionManager::State::ACTIVE, arc_session_manager()->state()); 502 EXPECT_EQ(ArcSessionManager::State::ACTIVE, arc_session_manager()->state());
503 EXPECT_FALSE(prefs->GetBoolean(prefs::kArcBackupRestoreEnabled)); 503 EXPECT_FALSE(prefs->GetBoolean(prefs::kArcBackupRestoreEnabled));
504 EXPECT_FALSE(prefs->GetBoolean(prefs::kArcLocationServiceEnabled)); 504 EXPECT_FALSE(prefs->GetBoolean(prefs::kArcLocationServiceEnabled));
505 505
506 // Stop ARC and shutdown the service. 506 // Stop ARC and shutdown the service.
507 prefs->RemoveManagedPref(prefs::kArcEnabled); 507 prefs->RemoveManagedPref(prefs::kArcEnabled);
508 WaitForDataRemoved(ArcSessionManager::State::STOPPED); 508 WaitForDataRemoved(ArcSessionManager::State::STOPPED);
509 arc_session_manager()->Shutdown(); 509 arc_session_manager()->Shutdown();
510 } 510 }
511 511
512 TEST_P(ArcSessionManagerPolicyTest, ReenableManagedArc) {
513 sync_preferences::TestingPrefServiceSyncable* const prefs =
514 profile()->GetTestingPrefService();
515
516 // Set ARC to be managed.
517 prefs->SetManagedPref(prefs::kArcEnabled, new base::Value(true));
518 EXPECT_TRUE(arc::IsArcPlayStoreEnabledForProfile(profile()));
519
520 arc_session_manager()->SetProfile(profile());
521 arc_session_manager()->RequestEnable();
522 EXPECT_TRUE(arc_session_manager()->enable_requested());
523
524 // Simulate close OptIn. Session manager should stop.
525 SetArcPlayStoreEnabledForProfile(profile(), false);
526 EXPECT_TRUE(arc::IsArcPlayStoreEnabledForProfile(profile()));
527 EXPECT_FALSE(arc_session_manager()->enable_requested());
528
529 // Restart ARC again
530 SetArcPlayStoreEnabledForProfile(profile(), true);
531 EXPECT_TRUE(arc::IsArcPlayStoreEnabledForProfile(profile()));
532 EXPECT_TRUE(arc_session_manager()->enable_requested());
533
534 arc_session_manager()->Shutdown();
535 }
536
512 INSTANTIATE_TEST_CASE_P( 537 INSTANTIATE_TEST_CASE_P(
513 ArcSessionManagerPolicyTest, 538 ArcSessionManagerPolicyTest,
514 ArcSessionManagerPolicyTest, 539 ArcSessionManagerPolicyTest,
515 testing::Combine( 540 testing::Combine(
516 testing::Values(base::Value(), base::Value(false), base::Value(true)), 541 testing::Values(base::Value(), base::Value(false), base::Value(true)),
517 testing::Values(base::Value(), base::Value(false), base::Value(true)))); 542 testing::Values(base::Value(), base::Value(false), base::Value(true))));
518 543
519 class ArcSessionManagerKioskTest : public ArcSessionManagerTestBase { 544 class ArcSessionManagerKioskTest : public ArcSessionManagerTestBase {
520 public: 545 public:
521 ArcSessionManagerKioskTest() = default; 546 ArcSessionManagerKioskTest() = default;
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 arc_session_manager()->state()); 718 arc_session_manager()->state());
694 ReportResult(true); 719 ReportResult(true);
695 EXPECT_EQ(ArcSessionManager::State::ACTIVE, arc_session_manager()->state()); 720 EXPECT_EQ(ArcSessionManager::State::ACTIVE, arc_session_manager()->state());
696 } 721 }
697 722
698 TEST_P(ArcSessionOobeOptInNegotiatorTest, OobeTermsRejected) { 723 TEST_P(ArcSessionOobeOptInNegotiatorTest, OobeTermsRejected) {
699 view()->Show(); 724 view()->Show();
700 EXPECT_EQ(ArcSessionManager::State::SHOWING_TERMS_OF_SERVICE, 725 EXPECT_EQ(ArcSessionManager::State::SHOWING_TERMS_OF_SERVICE,
701 arc_session_manager()->state()); 726 arc_session_manager()->state());
702 ReportResult(false); 727 ReportResult(false);
703 EXPECT_EQ(ArcSessionManager::State::STOPPED, arc_session_manager()->state()); 728 if (!IsManagedUser()) {
729 // ArcPlayStoreEnabledPreferenceHandler is not running, so the state should
730 // be kept as is
731 EXPECT_EQ(/*ArcSessionManager::State::SHOWING_TERMS_OF_SERVICE,*/
732 ArcSessionManager::State::STOPPED, // M58 Only, different logic
733 arc_session_manager()->state());
734 EXPECT_FALSE(IsArcPlayStoreEnabledForProfile(profile()));
735 } else {
736 // For managed case we handle closing outside of
737 // ArcPlayStoreEnabledPreferenceHandler. So it session turns to STOPPED.
738 EXPECT_EQ(ArcSessionManager::State::STOPPED,
739 arc_session_manager()->state());
740 // Managed user's preference should not be overwritten.
741 EXPECT_TRUE(IsArcPlayStoreEnabledForProfile(profile()));
742 }
704 } 743 }
705 744
706 TEST_P(ArcSessionOobeOptInNegotiatorTest, OobeTermsViewDestroyed) { 745 TEST_P(ArcSessionOobeOptInNegotiatorTest, OobeTermsViewDestroyed) {
707 view()->Show(); 746 view()->Show();
708 EXPECT_EQ(ArcSessionManager::State::SHOWING_TERMS_OF_SERVICE, 747 EXPECT_EQ(ArcSessionManager::State::SHOWING_TERMS_OF_SERVICE,
709 arc_session_manager()->state()); 748 arc_session_manager()->state());
710 CloseLoginDisplayHost(); 749 CloseLoginDisplayHost();
711 ReportViewDestroyed(); 750 ReportViewDestroyed();
712 EXPECT_EQ(ArcSessionManager::State::STOPPED, arc_session_manager()->state()); 751 if (!IsManagedUser()) {
752 // ArcPlayStoreEnabledPreferenceHandler is not running, so the state should
753 // be kept as is.
754 EXPECT_EQ(/*ArcSessionManager::State::SHOWING_TERMS_OF_SERVICE,*/
755 ArcSessionManager::State::STOPPED, // M58 Only, different logic
756 arc_session_manager()->state());
757 EXPECT_FALSE(IsArcPlayStoreEnabledForProfile(profile()));
758 } else {
759 // For managed case we handle closing outside of
760 // ArcPlayStoreEnabledPreferenceHandler. So it session turns to STOPPED.
761 EXPECT_EQ(ArcSessionManager::State::STOPPED,
762 arc_session_manager()->state());
763 // Managed user's preference should not be overwritten.
764 EXPECT_TRUE(IsArcPlayStoreEnabledForProfile(profile()));
765 }
713 } 766 }
714 767
715 } // namespace arc 768 } // 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