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

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

Issue 2700303002: cros: Unify oobe View/Actor naming to just View. (Closed)
Patch Set: Created 3 years, 10 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 <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
12 #include "base/files/file_util.h" 12 #include "base/files/file_util.h"
13 #include "base/files/scoped_temp_dir.h" 13 #include "base/files/scoped_temp_dir.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/memory/ptr_util.h" 15 #include "base/memory/ptr_util.h"
16 #include "base/observer_list.h" 16 #include "base/observer_list.h"
17 #include "base/run_loop.h" 17 #include "base/run_loop.h"
18 #include "chrome/browser/chromeos/arc/arc_optin_uma.h" 18 #include "chrome/browser/chromeos/arc/arc_optin_uma.h"
19 #include "chrome/browser/chromeos/arc/arc_session_manager.h" 19 #include "chrome/browser/chromeos/arc/arc_session_manager.h"
20 #include "chrome/browser/chromeos/arc/optin/arc_terms_of_service_oobe_negotiator .h" 20 #include "chrome/browser/chromeos/arc/optin/arc_terms_of_service_oobe_negotiator .h"
21 #include "chrome/browser/chromeos/arc/test/arc_data_removed_waiter.h" 21 #include "chrome/browser/chromeos/arc/test/arc_data_removed_waiter.h"
22 #include "chrome/browser/chromeos/login/screens/arc_terms_of_service_screen_acto r.h" 22 #include "chrome/browser/chromeos/login/screens/arc_terms_of_service_screen_view .h"
23 #include "chrome/browser/chromeos/login/screens/arc_terms_of_service_screen_acto r_observer.h" 23 #include "chrome/browser/chromeos/login/screens/arc_terms_of_service_screen_view _observer.h"
24 #include "chrome/browser/chromeos/login/ui/login_display_host.h" 24 #include "chrome/browser/chromeos/login/ui/login_display_host.h"
25 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" 25 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h"
26 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" 26 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h"
27 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" 27 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h"
28 #include "chrome/browser/chromeos/profiles/profile_helper.h" 28 #include "chrome/browser/chromeos/profiles/profile_helper.h"
29 #include "chrome/browser/policy/profile_policy_connector.h" 29 #include "chrome/browser/policy/profile_policy_connector.h"
30 #include "chrome/browser/policy/profile_policy_connector_factory.h" 30 #include "chrome/browser/policy/profile_policy_connector_factory.h"
31 #include "chrome/browser/prefs/pref_service_syncable_util.h" 31 #include "chrome/browser/prefs/pref_service_syncable_util.h"
32 #include "chrome/browser/profiles/profile.h" 32 #include "chrome/browser/profiles/profile.h"
33 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" 33 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h"
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 CloseLoginDisplayHost(); 637 CloseLoginDisplayHost();
638 EXPECT_FALSE(ArcSessionManager::IsOobeOptInActive()); 638 EXPECT_FALSE(ArcSessionManager::IsOobeOptInActive());
639 GetFakeUserManager()->set_current_user_new(true); 639 GetFakeUserManager()->set_current_user_new(true);
640 EXPECT_FALSE(ArcSessionManager::IsOobeOptInActive()); 640 EXPECT_FALSE(ArcSessionManager::IsOobeOptInActive());
641 CreateLoginDisplayHost(); 641 CreateLoginDisplayHost();
642 EXPECT_TRUE(ArcSessionManager::IsOobeOptInActive()); 642 EXPECT_TRUE(ArcSessionManager::IsOobeOptInActive());
643 } 643 }
644 644
645 class ArcSessionOobeOptInNegotiatorTest 645 class ArcSessionOobeOptInNegotiatorTest
646 : public ArcSessionOobeOptInTest, 646 : public ArcSessionOobeOptInTest,
647 public chromeos::ArcTermsOfServiceScreenActor, 647 public chromeos::ArcTermsOfServiceScreenView,
648 public testing::WithParamInterface<bool> { 648 public testing::WithParamInterface<bool> {
649 public: 649 public:
650 ArcSessionOobeOptInNegotiatorTest() = default; 650 ArcSessionOobeOptInNegotiatorTest() = default;
651 651
652 void SetUp() override { 652 void SetUp() override {
653 ArcSessionOobeOptInTest::SetUp(); 653 ArcSessionOobeOptInTest::SetUp();
654 654
655 AppendEnableArcOOBEOptInSwitch(); 655 AppendEnableArcOOBEOptInSwitch();
656 656
657 ArcTermsOfServiceOobeNegotiator::SetArcTermsOfServiceScreenActorForTesting( 657 ArcTermsOfServiceOobeNegotiator::SetArcTermsOfServiceScreenActorForTesting(
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
692 if (accepted) 692 if (accepted)
693 observer.OnAccept(); 693 observer.OnAccept();
694 else 694 else
695 observer.OnSkip(); 695 observer.OnSkip();
696 } 696 }
697 base::RunLoop().RunUntilIdle(); 697 base::RunLoop().RunUntilIdle();
698 } 698 }
699 699
700 void ReportActorDestroyed() { 700 void ReportActorDestroyed() {
701 for (auto& observer : observer_list_) 701 for (auto& observer : observer_list_)
702 observer.OnActorDestroyed(this); 702 observer.OnViewDestroyed(this);
703 base::RunLoop().RunUntilIdle(); 703 base::RunLoop().RunUntilIdle();
704 } 704 }
705 705
706 void MaybeWaitForDataRemoved() { 706 void MaybeWaitForDataRemoved() {
707 // In case of managed user we no need to wait data removal because 707 // In case of managed user we no need to wait data removal because
708 // ArcSessionManager is initialized with arc.enabled = true already and 708 // ArcSessionManager is initialized with arc.enabled = true already and
709 // request to remove ARC data is not issued. 709 // request to remove ARC data is not issued.
710 if (IsManagedUser()) 710 if (IsManagedUser())
711 return; 711 return;
712 712
713 DCHECK_EQ(ArcSessionManager::State::REMOVING_DATA_DIR, 713 DCHECK_EQ(ArcSessionManager::State::REMOVING_DATA_DIR,
714 ArcSessionManager::Get()->state()); 714 ArcSessionManager::Get()->state());
715 ArcDataRemovedWaiter().Wait(); 715 ArcDataRemovedWaiter().Wait();
716 } 716 }
717 717
718 chromeos::ArcTermsOfServiceScreenActor* actor() { return this; } 718 chromeos::ArcTermsOfServiceScreenView* view() { return this; }
719 719
720 private: 720 private:
721 // ArcTermsOfServiceScreenActor: 721 // ArcTermsOfServiceScreenView:
722 void AddObserver( 722 void AddObserver(
723 chromeos::ArcTermsOfServiceScreenActorObserver* observer) override { 723 chromeos::ArcTermsOfServiceScreenViewObserver* observer) override {
724 observer_list_.AddObserver(observer); 724 observer_list_.AddObserver(observer);
725 } 725 }
726 726
727 void RemoveObserver( 727 void RemoveObserver(
728 chromeos::ArcTermsOfServiceScreenActorObserver* observer) override { 728 chromeos::ArcTermsOfServiceScreenViewObserver* observer) override {
729 observer_list_.RemoveObserver(observer); 729 observer_list_.RemoveObserver(observer);
730 } 730 }
731 731
732 void Show() override { 732 void Show() override {
733 // To match ArcTermsOfServiceScreenHandler logic where prefs::kArcEnabled is 733 // To match ArcTermsOfServiceScreenHandler logic where prefs::kArcEnabled is
734 // set to true on showing UI. 734 // set to true on showing UI.
735 profile()->GetPrefs()->SetBoolean(prefs::kArcEnabled, true); 735 profile()->GetPrefs()->SetBoolean(prefs::kArcEnabled, true);
736 } 736 }
737 737
738 void Hide() override {} 738 void Hide() override {}
739 739
740 base::ObserverList<chromeos::ArcTermsOfServiceScreenActorObserver> 740 base::ObserverList<chromeos::ArcTermsOfServiceScreenViewObserver>
741 observer_list_; 741 observer_list_;
742 742
743 DISALLOW_COPY_AND_ASSIGN(ArcSessionOobeOptInNegotiatorTest); 743 DISALLOW_COPY_AND_ASSIGN(ArcSessionOobeOptInNegotiatorTest);
744 }; 744 };
745 745
746 INSTANTIATE_TEST_CASE_P(ArcSessionOobeOptInNegotiatorTestImpl, 746 INSTANTIATE_TEST_CASE_P(ArcSessionOobeOptInNegotiatorTestImpl,
747 ArcSessionOobeOptInNegotiatorTest, 747 ArcSessionOobeOptInNegotiatorTest,
748 ::testing::Values(true, false)); 748 ::testing::Values(true, false));
749 749
750 TEST_P(ArcSessionOobeOptInNegotiatorTest, OobeTermsAccepted) { 750 TEST_P(ArcSessionOobeOptInNegotiatorTest, OobeTermsAccepted) {
751 actor()->Show(); 751 view()->Show();
752 MaybeWaitForDataRemoved(); 752 MaybeWaitForDataRemoved();
753 EXPECT_EQ(ArcSessionManager::State::SHOWING_TERMS_OF_SERVICE, 753 EXPECT_EQ(ArcSessionManager::State::SHOWING_TERMS_OF_SERVICE,
754 arc_session_manager()->state()); 754 arc_session_manager()->state());
755 ReportResult(true); 755 ReportResult(true);
756 EXPECT_EQ(ArcSessionManager::State::ACTIVE, arc_session_manager()->state()); 756 EXPECT_EQ(ArcSessionManager::State::ACTIVE, arc_session_manager()->state());
757 EXPECT_TRUE(arc_session_manager()->IsArcPlayStoreEnabled()); 757 EXPECT_TRUE(arc_session_manager()->IsArcPlayStoreEnabled());
758 } 758 }
759 759
760 TEST_P(ArcSessionOobeOptInNegotiatorTest, OobeTermsRejected) { 760 TEST_P(ArcSessionOobeOptInNegotiatorTest, OobeTermsRejected) {
761 actor()->Show(); 761 view()->Show();
762 MaybeWaitForDataRemoved(); 762 MaybeWaitForDataRemoved();
763 EXPECT_EQ(ArcSessionManager::State::SHOWING_TERMS_OF_SERVICE, 763 EXPECT_EQ(ArcSessionManager::State::SHOWING_TERMS_OF_SERVICE,
764 arc_session_manager()->state()); 764 arc_session_manager()->state());
765 ReportResult(false); 765 ReportResult(false);
766 EXPECT_EQ(ArcSessionManager::State::STOPPED, arc_session_manager()->state()); 766 EXPECT_EQ(ArcSessionManager::State::STOPPED, arc_session_manager()->state());
767 EXPECT_FALSE(!IsManagedUser() && 767 EXPECT_FALSE(!IsManagedUser() &&
768 arc_session_manager()->IsArcPlayStoreEnabled()); 768 arc_session_manager()->IsArcPlayStoreEnabled());
769 } 769 }
770 770
771 TEST_P(ArcSessionOobeOptInNegotiatorTest, OobeTermsActorDestroyed) { 771 TEST_P(ArcSessionOobeOptInNegotiatorTest, OobeTermsActorDestroyed) {
772 actor()->Show(); 772 view()->Show();
773 MaybeWaitForDataRemoved(); 773 MaybeWaitForDataRemoved();
774 EXPECT_EQ(ArcSessionManager::State::SHOWING_TERMS_OF_SERVICE, 774 EXPECT_EQ(ArcSessionManager::State::SHOWING_TERMS_OF_SERVICE,
775 arc_session_manager()->state()); 775 arc_session_manager()->state());
776 CloseLoginDisplayHost(); 776 CloseLoginDisplayHost();
777 ReportActorDestroyed(); 777 ReportActorDestroyed();
778 EXPECT_EQ(ArcSessionManager::State::STOPPED, arc_session_manager()->state()); 778 EXPECT_EQ(ArcSessionManager::State::STOPPED, arc_session_manager()->state());
779 EXPECT_FALSE(!IsManagedUser() && 779 EXPECT_FALSE(!IsManagedUser() &&
780 arc_session_manager()->IsArcPlayStoreEnabled()); 780 arc_session_manager()->IsArcPlayStoreEnabled());
781 } 781 }
782 782
783 } // namespace arc 783 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698