| OLD | NEW |
| 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/arc_util.h" |
| 20 #include "chrome/browser/chromeos/arc/optin/arc_terms_of_service_oobe_negotiator
.h" | 21 #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" | 22 #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" | 23 #include "chrome/browser/chromeos/login/screens/arc_terms_of_service_screen_acto
r.h" |
| 23 #include "chrome/browser/chromeos/login/screens/arc_terms_of_service_screen_acto
r_observer.h" | 24 #include "chrome/browser/chromeos/login/screens/arc_terms_of_service_screen_acto
r_observer.h" |
| 24 #include "chrome/browser/chromeos/login/ui/login_display_host.h" | 25 #include "chrome/browser/chromeos/login/ui/login_display_host.h" |
| 25 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" | 26 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" |
| 26 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" | 27 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" |
| 27 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" | 28 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" |
| 28 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 29 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 29 #include "chrome/browser/policy/profile_policy_connector.h" | 30 #include "chrome/browser/policy/profile_policy_connector.h" |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 ASSERT_EQ(ArcSessionManager::State::ACTIVE, arc_session_manager()->state()); | 370 ASSERT_EQ(ArcSessionManager::State::ACTIVE, arc_session_manager()->state()); |
| 370 | 371 |
| 371 arc_session_manager()->CancelAuthCode(); | 372 arc_session_manager()->CancelAuthCode(); |
| 372 ASSERT_EQ(ArcSessionManager::State::ACTIVE, arc_session_manager()->state()); | 373 ASSERT_EQ(ArcSessionManager::State::ACTIVE, arc_session_manager()->state()); |
| 373 ASSERT_TRUE(pref->GetBoolean(prefs::kArcEnabled)); | 374 ASSERT_TRUE(pref->GetBoolean(prefs::kArcEnabled)); |
| 374 | 375 |
| 375 // Correctly stop service. | 376 // Correctly stop service. |
| 376 arc_session_manager()->Shutdown(); | 377 arc_session_manager()->Shutdown(); |
| 377 } | 378 } |
| 378 | 379 |
| 379 TEST_F(ArcSessionManagerTest, EnableDisablesArc) { | |
| 380 const PrefService* pref = profile()->GetPrefs(); | |
| 381 arc_session_manager()->OnPrimaryUserProfilePrepared(profile()); | |
| 382 | |
| 383 EXPECT_FALSE(pref->GetBoolean(prefs::kArcEnabled)); | |
| 384 arc_session_manager()->SetArcPlayStoreEnabled(true); | |
| 385 EXPECT_TRUE(pref->GetBoolean(prefs::kArcEnabled)); | |
| 386 arc_session_manager()->SetArcPlayStoreEnabled(false); | |
| 387 EXPECT_FALSE(pref->GetBoolean(prefs::kArcEnabled)); | |
| 388 | |
| 389 // Correctly stop service. | |
| 390 arc_session_manager()->Shutdown(); | |
| 391 } | |
| 392 | |
| 393 TEST_F(ArcSessionManagerTest, SignInStatus) { | 380 TEST_F(ArcSessionManagerTest, SignInStatus) { |
| 394 PrefService* const prefs = profile()->GetPrefs(); | 381 PrefService* const prefs = profile()->GetPrefs(); |
| 395 | 382 |
| 396 EXPECT_TRUE(arc_session_manager()->sign_in_start_time().is_null()); | 383 EXPECT_TRUE(arc_session_manager()->sign_in_start_time().is_null()); |
| 397 EXPECT_TRUE(arc_session_manager()->arc_start_time().is_null()); | 384 EXPECT_TRUE(arc_session_manager()->arc_start_time().is_null()); |
| 398 | 385 |
| 399 EXPECT_FALSE(prefs->GetBoolean(prefs::kArcSignedIn)); | 386 EXPECT_FALSE(prefs->GetBoolean(prefs::kArcSignedIn)); |
| 400 prefs->SetBoolean(prefs::kArcEnabled, true); | 387 prefs->SetBoolean(prefs::kArcEnabled, true); |
| 401 | 388 |
| 402 arc_session_manager()->OnPrimaryUserProfilePrepared(profile()); | 389 arc_session_manager()->OnPrimaryUserProfilePrepared(profile()); |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 747 ArcSessionOobeOptInNegotiatorTest, | 734 ArcSessionOobeOptInNegotiatorTest, |
| 748 ::testing::Values(true, false)); | 735 ::testing::Values(true, false)); |
| 749 | 736 |
| 750 TEST_P(ArcSessionOobeOptInNegotiatorTest, OobeTermsAccepted) { | 737 TEST_P(ArcSessionOobeOptInNegotiatorTest, OobeTermsAccepted) { |
| 751 actor()->Show(); | 738 actor()->Show(); |
| 752 MaybeWaitForDataRemoved(); | 739 MaybeWaitForDataRemoved(); |
| 753 EXPECT_EQ(ArcSessionManager::State::SHOWING_TERMS_OF_SERVICE, | 740 EXPECT_EQ(ArcSessionManager::State::SHOWING_TERMS_OF_SERVICE, |
| 754 arc_session_manager()->state()); | 741 arc_session_manager()->state()); |
| 755 ReportResult(true); | 742 ReportResult(true); |
| 756 EXPECT_EQ(ArcSessionManager::State::ACTIVE, arc_session_manager()->state()); | 743 EXPECT_EQ(ArcSessionManager::State::ACTIVE, arc_session_manager()->state()); |
| 757 EXPECT_TRUE(arc_session_manager()->IsArcPlayStoreEnabled()); | 744 EXPECT_TRUE(IsArcPlayStoreEnabledForProfile(profile())); |
| 758 } | 745 } |
| 759 | 746 |
| 760 TEST_P(ArcSessionOobeOptInNegotiatorTest, OobeTermsRejected) { | 747 TEST_P(ArcSessionOobeOptInNegotiatorTest, OobeTermsRejected) { |
| 761 actor()->Show(); | 748 actor()->Show(); |
| 762 MaybeWaitForDataRemoved(); | 749 MaybeWaitForDataRemoved(); |
| 763 EXPECT_EQ(ArcSessionManager::State::SHOWING_TERMS_OF_SERVICE, | 750 EXPECT_EQ(ArcSessionManager::State::SHOWING_TERMS_OF_SERVICE, |
| 764 arc_session_manager()->state()); | 751 arc_session_manager()->state()); |
| 765 ReportResult(false); | 752 ReportResult(false); |
| 766 EXPECT_EQ(ArcSessionManager::State::STOPPED, arc_session_manager()->state()); | 753 EXPECT_EQ(ArcSessionManager::State::STOPPED, arc_session_manager()->state()); |
| 767 EXPECT_FALSE(!IsManagedUser() && | 754 if (!IsManagedUser()) |
| 768 arc_session_manager()->IsArcPlayStoreEnabled()); | 755 EXPECT_FALSE(IsArcPlayStoreEnabledForProfile(profile())); |
| 769 } | 756 } |
| 770 | 757 |
| 771 TEST_P(ArcSessionOobeOptInNegotiatorTest, OobeTermsActorDestroyed) { | 758 TEST_P(ArcSessionOobeOptInNegotiatorTest, OobeTermsActorDestroyed) { |
| 772 actor()->Show(); | 759 actor()->Show(); |
| 773 MaybeWaitForDataRemoved(); | 760 MaybeWaitForDataRemoved(); |
| 774 EXPECT_EQ(ArcSessionManager::State::SHOWING_TERMS_OF_SERVICE, | 761 EXPECT_EQ(ArcSessionManager::State::SHOWING_TERMS_OF_SERVICE, |
| 775 arc_session_manager()->state()); | 762 arc_session_manager()->state()); |
| 776 CloseLoginDisplayHost(); | 763 CloseLoginDisplayHost(); |
| 777 ReportActorDestroyed(); | 764 ReportActorDestroyed(); |
| 778 EXPECT_EQ(ArcSessionManager::State::STOPPED, arc_session_manager()->state()); | 765 EXPECT_EQ(ArcSessionManager::State::STOPPED, arc_session_manager()->state()); |
| 779 EXPECT_FALSE(!IsManagedUser() && | 766 if (!IsManagedUser()) |
| 780 arc_session_manager()->IsArcPlayStoreEnabled()); | 767 EXPECT_FALSE(IsArcPlayStoreEnabledForProfile(profile())); |
| 781 } | 768 } |
| 782 | 769 |
| 783 } // namespace arc | 770 } // namespace arc |
| OLD | NEW |